Commit Graph

68 Commits

Author SHA1 Message Date
Ariel Mashraki
3c6a04f884 entc/gen: add default-funcs and validators for userdefined id (#436)
Fixes #432
2020-04-18 12:28:50 +03:00
Ariel Mashraki
2ea4268414 entc/gen: add schema checks for types (#418) 2020-04-01 22:53:02 +03:00
Ariel Mashraki
de5006a4d8 entc/gen: lazy compute storage-driver queries (#408) 2020-03-29 14:36:44 +03:00
Ariel Mashraki
65f96b3593 entc/gen: remove legacy i2a support for ids (#389)
* entc/gen: remove legacy i2a support for ids

* integ: add customid tests for fk strings
2020-03-16 18:19:30 +02:00
Ariel Mashraki
15cbc5c223 entc/gen: unexport capitalized schema fields in mutations (#388) 2020-03-16 11:21:05 +02: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
7114543a08 entc/gen: fix nulltype field name for float32 (#381)
Fixes #380
2020-03-07 19:12:59 +02:00
Ariel Mashraki
dc222c0b15 entc/gen: remove example_test template from codegen (#351)
Fixes #297
2020-02-18 12:26:46 +02:00
Ariel Mashraki
bb852ad093 intgeration: add pg and mysql test for customids (#342) 2020-02-12 20:42:03 +02:00
Ariel Mashraki
9733051cc3 entc/gen: currently handle user-defined string ids (#338)
Fixes #127
2020-02-10 12:04:50 +02:00
Ariel Mashraki
caf721df47 entc/gen: add eager-loading support (#263)
* entc/gen: add OwnFK indicator for type edges

* entc/gen: add Edges field for generated types

* entc/gen: add With<T> method to query-builder template

* entc/gen: scan and assign foreign-keys on eager-loading

* entc/gen: load fk-relations (wip)

* entc/integration: add o2m/m2o tests for eager-loading

* entc/gen: add m2m support for eager-loading

* entc/gen: add integration tests for m2m and subgraphs

* entc/gen/integration: add tests for o2o eager-loading

* all: generate all assets
2020-01-13 17:21:26 +02:00
Ariel Mashraki
9cb0eb7467 entc/gen: reject fields without name (#273)
Fixes #272
2020-01-06 21:30:25 +02:00
Ariel Mashraki
b54007ef56 Entc/enums (#271)
* ent: add default value setter to enum builder

Co-authored-by: Dario Ielardi <dario.ielardi@gmail.com>
2020-01-05 18:31:35 +02:00
Jian Li
fc6a9b1a9b fix meta.tmpl code generating incomplete issue. (#268) 2020-01-05 08:12:45 +02:00
Ariel Mashraki
7a85c04c32 entc/gen: add edge-fields + minor changes 2019-12-23 10:57:36 +02:00
Ariel Mashraki
67c3fd2db9 entc/gen: initial work for supporting uuid fields in codegen
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/182

Reviewed By: alexsn

Differential Revision: D18638199

fbshipit-source-id: 0de79c78b51e544486c07a004c3c8ea82e5c3398
2019-11-24 07:11:23 -08:00
Ariel Mashraki
e54373f410 ent: allow non-numeric columns as PKs
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/180

Reviewed By: alexsn

Differential Revision: D18636443

fbshipit-source-id: f14b34926817f6d9652f49a640bfb377f3f3cdaf
2019-11-21 08:49:58 -08:00
Ariel Mashraki
7be1779ad1 entc/gen: add the type name as an index prefix (#171)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/171

Note that this is a non backwards compatible change.

I'll add another change (before this) for setting the storage-key of the index, and only after that we can land this.

Reviewed By: alexsn

Differential Revision: D18570445

fbshipit-source-id: e3ffc7b4baa6bc2fcce9e4553e17817091423b1e
2019-11-20 07:08:47 -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
d9da7243f9 entc/gen: initial support for user-defined ids
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/162

Reviewed By: alexsn

Differential Revision: D18485086

fbshipit-source-id: 9bb6ccff592bc0cb8b218625161ed492f67bc170
2019-11-14 08:21:31 -08:00
Ariel Mashraki
e161ecc29c cmd/entc: remove graph printing from generator
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/163

Reviewed By: alexsn

Differential Revision: D18503829

fbshipit-source-id: 1269d4c8c30f848c5096258f2328230f5f378f69
2019-11-14 08:21:30 -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
Ariel Mashraki
3ac23d8420 entc/gen: allow defining index only on edges (#152)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/152

Fixes #150

Reviewed By: idoshveki

Differential Revision: D18419810

fbshipit-source-id: aeabd9c3379d4456235884abeca01407569cd7dc
2019-11-10 02:56:34 -08:00
Ariel Mashraki
4aa550a68f entc/gen: avoid ambiguous selector error when adding config field
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/147

Reviewed By: alexsn

Differential Revision: D18380088

fbshipit-source-id: 8173b0082b69eda4e623da618a54d443b34d20eb
2019-11-07 22:08:33 -08: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
Ariel Mashraki
36a3971f3d entc/gen: add struct field name to fields and edges
Summary: avoig logic in templates

Reviewed By: alexsn

Differential Revision: D17926168

fbshipit-source-id: d583e800fb4a45cf939e9788cea6d45e126c61fe
2019-10-15 06:42:44 -07:00
Ariel Mashraki
64ed7580c0 entc/gen: use BuilderField for builder memebrs
Summary: StructField should be used a member of the ent type (struct), and logic should be removed from templates.

Reviewed By: alexsn

Differential Revision: D17926151

fbshipit-source-id: f77c5ce8359816ec3a4ce1ab71dd98f205706deb
2019-10-15 06:42:44 -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
Ariel Mashraki
766940563f ent/gen: set currect storage-key for indexes
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/66

Reviewed By: alexsn

Differential Revision: D17779042

fbshipit-source-id: 12be885b20f91eb611a41e361650f7a66747fab0
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
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
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
Ariel Mashraki
bd6d7cc647 entc/gen: use default name in column construction
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/41

Reviewed By: alexsn

Differential Revision: D17599004

fbshipit-source-id: 928d82fe689ca1c528ec204c3fb6e2732cb58f0b
2019-09-26 05:59:26 -07:00
Alex Snast
dacc568413 ent/entc: corrently reference default value on migrate generation
Summary:
Migration incorrectly generated field default value on storage key inclusion.

Example Field:
```
field.String("tenant").
  StorageKey("organization").
  Default("fb-test"),
```
Generated default of:
```
// DefaultTenant holds the default value on creation for the tenant field.
DefaultTenant = descTenant.Default.(string)
```
But migration references non existent default (storage key is used):
```
{Name: "organization", Type: field.TypeString, Default: user.DefaultOrganization},
```

Reviewed By: a8m

Differential Revision: D17578898

fbshipit-source-id: afca92ac3f34c16100c868a10d0a480139bf4262
2019-09-25 13:51:45 -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
0f71ca6ad8 entc/cmd/entc: support more numeric types for ids
Reviewed By: alexsn

Differential Revision: D17527952

fbshipit-source-id: 1465b054531cee8ca1dd445b6654063f32f4c4e3
2019-09-23 09:48:24 -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
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
78a7509c52 entc: clear optional field values
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/33

Reviewed By: noamsch

Differential Revision: D17344992

fbshipit-source-id: 5336e9c5a4978e10923e26b5754942d92371a5cd
2019-09-15 04:44:55 -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
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
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
62772e0c85 entc/gen: fix broken ut
Reviewed By: alexsn

Differential Revision: D17073367

fbshipit-source-id: 03b36366c6dbd3fa0a0a5ca98bca907945063081
2019-08-27 09:38:52 -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
52292557f6 entc/indexes: inverse only restriction applies only on O2O relation
Reviewed By: alexsn

Differential Revision: D17004823

fbshipit-source-id: 08b62960b447a157419dbeefd80ca1fcd29efd76
2019-08-25 06:41:14 -07:00
Alex Snast
e6a1333b9d ent/schema: allow multi from edges on ent index
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/24

Reviewed By: a8m

Differential Revision: D16961315

fbshipit-source-id: cd7cd0fe2555dc1acc2ad7301d92b5b4cd042a39
2019-08-22 07:00:29 -07:00