Commit Graph

68 Commits

Author SHA1 Message Date
Ariel Mashraki
47f1a203aa schema/edge: an storage-key option for edges (#545)
* schema/edge: an storage-key option for edges

* schema/edge: use Column(s) with functional options
2020-06-15 23:06:00 +03:00
Ariel Mashraki
31690c7e60 schema/field: add Err method to field descriptor (#498) 2020-05-21 22:06:49 +03:00
Ariel Mashraki
9b14556314 entc/load: report mixin name on failures (#476) 2020-05-08 14:17:55 +03:00
Ariel Mashraki
6fbb5b6b4a entc/load: add schema-type field for schema (#459) 2020-05-04 19:35:40 +03:00
Ariel Mashraki
1c49159d18 entc/gen: add indexes, edges and hooks to mixin (#431) 2020-04-20 13:40:56 +03:00
Ariel Mashraki
7988d3084d entc/hooks: initial work for mutations and hooks (#377)
* entc/hooks: initial work for mutations and hooks

* ent/schema: adding policy to schema

* ent: change op string to uint

* entc: move entschema to runtime and enable smooth transition

* entc/privacy: adding privacy template

* all: goimports

* intg/hooks: mutation client/tx and basic schema tests

* ent/privacy: adding more verbose decisions

* entc/gen: edge-ids getter and additional tests

* all: regen assets

* entc/gen: fix client hookd propagation

* intg: add deletion example

* intg/privacy: remove old entschema package

* typed privacy

* ent/privacy: hooks shouldn't be called on privacy deny

* entc/gen: fix schema hooks invocation order

* remove read policy from public api

* update circleci go orb

Co-authored-by: Ariel Mashraki <ariel@mashraki.co.il>
2020-03-16 00:19:27 +02:00
Ariel Mashraki
bb852ad093 intgeration: add pg and mysql test for customids (#342) 2020-02-12 20:42:03 +02:00
Ariel Mashraki
d2fe7199e5 entc/load: return packages.Load error when 'go list' fails (#187)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/187

Also, remove the dependency of pkg/errors from load package.

Reviewed By: alexsn

Differential Revision: D18672979

fbshipit-source-id: 88a881a99e93896f8d3a0aefcf61fbd995b7fa08
2019-11-24 07:11:22 -08:00
Ariel Mashraki
1e49561634 ent: support external uuid types (#181)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/181

The lack of generic typing requires to check the function type in the "loading" phase of the schema.

Reviewed By: alexsn

Differential Revision: D18636969

fbshipit-source-id: d8229779bf3c2490e51f5d0d4c550c70e2cd2550
2019-11-21 08:49:59 -08:00
Ariel Mashraki
3c6661fce8 schema/index: add storage-key option for indexes
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/172

Reviewed By: alexsn

Differential Revision: D18571700

fbshipit-source-id: 2b8dbcc7c36be01ba383c48f982f59361a68c621
2019-11-18 07:54:56 -08:00
Ariel Mashraki
829de26c4f entc/load: add the default value for schema fields when possible (#170)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/170

Used to verify enum default values in the genrator

Reviewed By: alexsn

Differential Revision: D18561625

fbshipit-source-id: fde153a042d2e7b6da7f7d2c5b045c93266e276f
2019-11-17 09:06:58 -08:00
Ariel Mashraki
6ce4cb6803 all: fix minor lint errors
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/159

Reviewed By: dlvhdr

Differential Revision: D18476131

fbshipit-source-id: 9e792f5a35f25233aad73f75f12d13d215a21ad2
2019-11-13 06:01:41 -08:00
Alex Snast
75f59d76ad ent/entc: drop modtime from generated bindata
Summary: Keep bindata code consistent accross `go generate` executions.

Reviewed By: a8m

Differential Revision: D17977276

fbshipit-source-id: 7bc1eecf23f59c0732399ec69e484a594a611d31
2019-10-17 01:55:41 -07:00
Ariel Mashraki
c6b395904c entc/load: avoid panic due to index out of range (#99)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/99

go/packages now returns partial packages instead of error and this can cause an index of out range.

Reviewed By: alexsn

Differential Revision: D17939156

fbshipit-source-id: d02867a0cca5f1e90ac4952ac4136d8c8086a944
2019-10-15 22:17:02 -07:00
Ariel Mashraki
c5b790043c entc: change the way we inject additional fields (#1560)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1560

Pull Request resolved: https://github.com/facebookincubator/ent/pull/96

Reviewed By: alexsn

Differential Revision: D17931147

fbshipit-source-id: 24e1d72be482cb787c557f46feeb2ed4a31dfe60
2019-10-15 12:00:46 -07:00
Alex Snast
5d988870bc ent/entc: use select/scan on id query (#1552)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1552

Pull Request resolved: https://github.com/facebookincubator/ent/pull/93

avoids complete ent load on id query

Reviewed By: a8m

Differential Revision: D17906002

fbshipit-source-id: 7749a0d7c707858eab368978a1d220b581ea6dbb
2019-10-14 23:16:14 -07:00
Ariel Mashraki
c2418a1907 entc/gen: suspended goimports after files were written (#89)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/89

We can't run "imports" on files when the state is not completed. Because, "goimports" will drop undefined package. Therefore, it's suspended to end of the writing.

Fixed #88

Reviewed By: alexsn

Differential Revision: D17899321

fbshipit-source-id: 198dae11b121869764ebc9eee92110caf4256bed
2019-10-13 07:03:11 -07:00
Ariel Mashraki
6f5f42ab3c dialect/sql: dialect based builders (#1550)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1550

Pull Request resolved: https://github.com/facebookincubator/ent/pull/84

This is still WIP and you should ignore this.

Reviewed By: alexsn

Differential Revision: D17854477

fbshipit-source-id: 2d19713c118adb31164b7a2781327e64c87db8d4
2019-10-13 07:03:11 -07:00
Alex Snast
ce2bc07c1a ent/circleci: adding linter tests
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/80

Reviewed By: a8m

Differential Revision: D17837182

fbshipit-source-id: 9fb539fd6cebc064d2d2804bd52e0fbf413cfc93
2019-10-10 04:45:07 -07:00
Ido Shveki
3d0d8724b0 ent/schema: adding sensitive fields support (#75)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/75

Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1539

Supporting "Sensitive" mode for string fields.

Reviewed By: a8m

Differential Revision: D17786543

fbshipit-source-id: a4d022c1436472cb525cdd50663dd0ce23d13699
2019-10-07 07:46:28 -07:00
Ariel Mashraki
7597f07912 entc: add option to use entc as package
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/72

Reviewed By: alexsn

Differential Revision: D17783580

fbshipit-source-id: 597f124a28415fef66b0b16811ad2acac8df631d
2019-10-07 07:06:32 -07:00
Alex Snast
e668326c5e ent/entc: set go-bindata version in go.mod (#74)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/74

don't rely on local go-bindata binary

Reviewed By: a8m

Differential Revision: D17786303

fbshipit-source-id: 1d1258478fd8f3abcdb3a7b1b06d0601b4468c94
2019-10-07 02:20:47 -07:00
Alex Snast
ac50ea81d4 ent: address several lint errors throughout the project (#1534)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1534

Pull Request resolved: https://github.com/facebookincubator/ent/pull/73

lint errors detected by running `golangci-lint` tool.

Reviewed By: a8m

Differential Revision: D17784980

fbshipit-source-id: f7e8bd99fdf1e018d5672cea1e8d44b67f2a4201
2019-10-06 23:59:12 -07:00
Ariel Mashraki
b64330e475 ent/gen: remove redundant nillable check
Summary: nillable must be optional

Reviewed By: alexsn

Differential Revision: D17763004

fbshipit-source-id: 9c134e1648d1a387d90a5f2353de855a1aa3464f
2019-10-05 11:03:05 -07:00
Ariel Mashraki
fc3e7f0a70 all: minor style changes
Reviewed By: noamsch

Differential Revision: D17763014

fbshipit-source-id: ba574059dcd93e7b02e22b6eac7c6a637bf5ba30
2019-10-05 11:03:05 -07:00
Ariel Mashraki
1750d33bd8 all: add support for running examples in playground
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/49

Reviewed By: alexsn

Differential Revision: D17735758

fbshipit-source-id: d4b80631e56870690cc54912528c9950f4e48ccc
2019-10-03 03:05:40 -07:00
Ariel Mashraki
1ebfa489c5 ent: add support for enum types
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/45

Reviewed By: alexsn

Differential Revision: D17715085

fbshipit-source-id: 7472e1bd9cf7a8a5bd98f96e6e884c0e27f36803
2019-10-02 12:55:28 -07:00
Ariel Mashraki
cb1f78f233 entc/gen: add open func for creating client
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/44

Reviewed By: alexsn

Differential Revision: D17657719

fbshipit-source-id: 9bbe18dc0e9c553f8a2df81018d7db06f38f5e0e
2019-10-02 01:41:40 -07:00
Ariel Mashraki
4dbebe68ff entc: add codegen support for mixin
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/43

Reviewed By: alexsn

Differential Revision: D17600868

fbshipit-source-id: 39a242a541fa2a2dd2db1c9919fecf192ff098bf
2019-09-26 07:41:11 -07:00
Alex Snast
6cf5b918c3 ent/entc: keep struct tags sorted
Summary: keeping tags sorted will prevent codegen changes due to random map key ordering

Reviewed By: a8m

Differential Revision: D17571598

fbshipit-source-id: 12afc4aa0d030aa178e6568eb7c768ccc159f726
2019-09-25 06:48:01 -07:00
Ariel Mashraki
3f7553af20 entc/gen: add tag ignoring for private fields
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1487

Reviewed By: alexsn

Differential Revision: D17527793

fbshipit-source-id: b264706b8af74ff94d384dddd1b5a14661478676
2019-09-23 09:48:24 -07:00
Ariel Mashraki
76f5b6ec5f ent/schema: add config for customize schema options
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/40

Reviewed By: alexsn

Differential Revision: D17480104

fbshipit-source-id: 5223430e3b2223b8471a85bd1d85b445f23acfce
2019-09-22 01:38:07 -07:00
Ariel Mashraki
c3955a08f1 schema/field: json type support (#38)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/38

Only `IsNil` and `NotNil` predicates are supported this moment

Reviewed By: alexsn

Differential Revision: D17444976

fbshipit-source-id: 37336fa0bc7749af995933baee2e23bb7366dd78
2019-09-19 05:00:11 -07:00
Ariel Mashraki
83d0063437 entc/gen: returns affected rows in delete
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1455

Reviewed By: alexsn

Differential Revision: D17396880

fbshipit-source-id: 3a3a9849b816777bd0ef94cf55b2291705a37df6
2019-09-16 08:47:42 -07:00
Alex Snast
2b1ff377b5 ent/entc: move Get / GetX operation under client
Summary: Saves typing `.Query()` every time we want to use `.Get()`

Reviewed By: a8m

Differential Revision: D17396667

fbshipit-source-id: 103c10d25bd1181b8e52fa272f2c1a26f47ed9f6
2019-09-16 07:44:41 -07:00
Ariel Mashraki
624ecd2cc7 schema/field: add storage-key option
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/35

Reviewed By: alexsn

Differential Revision: D17394930

fbshipit-source-id: bc9d8cc6569ad457b93d47d26d143f2442f98df9
2019-09-16 04:39:17 -07:00
Ariel Mashraki
b2cedc6c95 entc: move bindata files to internal packages
Summary: godoc was showing "Code generated by go-bindata. (generated) DO NOT EDIT." in the package description and exposing its methods.

Reviewed By: alexsn

Differential Revision: D17253564

fbshipit-source-id: c82082b4fa6adfba2c2663efbfacefb6423f89d9
2019-09-08 10:14:53 -07:00
Ariel Mashraki
61b8ccea4a entc/load: enable adding additional fields to the generated entities
Summary: In some cases (like xwf auth service), you want to add additional fields to the generated model.

Reviewed By: alexsn

Differential Revision: D17223674

fbshipit-source-id: fb4be71b388c6bd107e6bac242133c237fe25599
2019-09-08 08:05:13 -07:00
Ariel Mashraki
3fcaf80ca4 entc/migrate: add an option to dump schema changes
Reviewed By: alexsn

Differential Revision: D17253145

fbshipit-source-id: 32640e60a8e149ac8774384db8e2ece29b9fec24
2019-09-08 06:28:58 -07:00
Ariel Mashraki
9ab0a28ffe entc/select: add selection api
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/27

Reviewed By: alexsn

Differential Revision: D17164536

fbshipit-source-id: f5caa80b05aff1ef8ec30d7a53256b00380d018c
2019-09-04 07:14:24 -07:00
Ariel Mashraki
4323141fe2 ent: add license and copyright to template files
Reviewed By: alexsn

Differential Revision: D17149292

fbshipit-source-id: 837de5fad988de1e54438b47584701f2fc35326d
2019-09-01 03:03:15 -07:00
Ariel Mashraki
5bc8568069 all: add license reference to README and add copyright headers to gencode
Reviewed By: alexsn

Differential Revision: D17119262

fbshipit-source-id: 046f095ca9432c920778db0edb2158dedb23c0a2
2019-08-30 08:46:03 -07:00
Alex Snast
b71ee6820b ent/schema: remove string field charset / collation settings
Summary: don't expose starage specific features in ent schema

Reviewed By: a8m

Differential Revision: D17111724

fbshipit-source-id: fca9e624b272c0db3fed14c511fa6cb07816a100
2019-08-29 07:38:39 -07:00
Ariel Mashraki
e7fec6f8f9 entc/gen: change verbose option to debug
Summary: Change the Verbose option to Debug

Reviewed By: alexsn

Differential Revision: D17091911

fbshipit-source-id: c5cf3e1c7f33f607076fe5c7da94e04b9f236218
2019-08-28 06:45:59 -07:00
Alex Snast
4c1f28d58f ent/schema: allow setting collation for string fields
Reviewed By: a8m

Differential Revision: D17090481

fbshipit-source-id: a08768c9bac4318a91bc6a067c85d6eb022c3024
2019-08-28 04:52:32 -07:00
Ariel Mashraki
9207ab5bb1 entc/integration: fix broken test
Reviewed By: alexsn

Differential Revision: D17090600

fbshipit-source-id: 53edd9bfdc794a2fc1669fb0ccde36ee6bdad0c1
2019-08-28 02:15:18 -07:00
Alex Snast
373769dfaf ent/gen: adding EqualFold predicate for string fields
Summary: Similar to `ContainsFold` predicate requires `--storage=sql` argument to be passed to entc.

Reviewed By: a8m

Differential Revision: D17074805

fbshipit-source-id: ced299154417fe2c9007cd6a7a504f53c8b2ef98
2019-08-27 10:48:53 -07:00
Ariel Mashraki
772b8a33f8 ent/field: add update_default option time field
Reviewed By: alexsn

Differential Revision: D17070907

fbshipit-source-id: 63c9ce75c58e524044c38f9461cb04e8e45c8017
2019-08-27 06:54:49 -07:00
Ariel Mashraki
bd07c86b60 all: add license header to all go files
Summary:
Used addlicense to generate this:
 addlicense -c "Facebook Inc" -f license_header .

example was taken from: https://github.com/facebook/litho/blob/master/lib/soloader/BUCK

Reviewed By: alexsn

Differential Revision: D17070152

fbshipit-source-id: e7b91398d7f6181727be3400c1872ad5f28e38ed
2019-08-27 04:48:28 -07:00
Ariel Mashraki
3e7270e835 ent/schema: change ent interafces for descriptor only
Summary: wip

Reviewed By: alexsn

Differential Revision: D17052576

fbshipit-source-id: 165faca2ff02c22bb76f164d81d406ce46ab04c4
2019-08-27 03:58:25 -07:00