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
c355ed49be
entc/gen: move set-neighbors logic from codegen to sqlgraph
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/183
Reviewed By: alexsn
Differential Revision: D18644179
fbshipit-source-id: 2f2b0c03811a09c4c11240e5161187afbb2ac553
2019-11-24 04:16:36 -08:00
Ariel Mashraki
2b2e056f05
entc/gen/sql: support custom-id on create
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/166
Reviewed By: alexsn
Differential Revision: D18514295
fbshipit-source-id: e5988552c5611cbad18476ab2d9c2155df1e6e0c
2019-11-14 14:38:58 -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
8093ec4127
entc/gen: avoid using Go keywords as variables on scan
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/161
Reviewed By: alexsn
Differential Revision: D18483166
fbshipit-source-id: 7273d284232c1bf515cc84326904b580fb70a0e3
2019-11-13 11:35:58 -08:00
Ariel Mashraki
514c0ff6d3
entc/gen: add support for adding client fields using template
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/155
Reviewed By: alexsn
Differential Revision: D18421223
fbshipit-source-id: 112d4d26d53a64e2c78640c6d508ba2d1d3a7791
2019-11-10 13:29:38 -08:00
Ariel Mashraki
53cfcb6e8b
dialect/sql: fix predicate builder on join
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/143
Reviewed By: idoshveki
Differential Revision: D18346652
fbshipit-source-id: e8c5d7eb3cefc16f52090de0d121e82cae058fc2
2019-11-06 05:21:26 -08:00
Ariel Mashraki
930a17b767
dialect/sql: add neighbors function ( #140 )
...
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/140
This part of the effort of moving logic from Go templates to shared packages.
Next diffs will migrate the neighbors-set and predicates as well.
Dedicated tests for `sql/dialect/graph.go` will be added in a follow-up diff.
Reviewed By: alexsn
Differential Revision: D18304531
fbshipit-source-id: 93e9cf2636b5b4525eb27305bd2708122cfd6e40
2019-11-05 13:08:48 -08:00
Hylke Visser
02bae0d652
Remove update validators for immutable fields ( #137 )
...
Summary:
This pull request modifies the update builder template so that it no longer generates code to validate immutable fields.
The first commit breaks the integration code by making the `number` field of `Card` immutable (the generated validation code references non-existent fields of `CardUpdate`/`CardUpdateOne`).
The second commit fixes the issue by making the `update/save` template not render validation code for immutable fields.
Pull Request resolved: https://github.com/facebookincubator/ent/pull/137
Differential Revision: D18288633
Pulled By: a8m
fbshipit-source-id: c0361b833a3971f76280d624f16cd7eda2725c1e
2019-11-02 09:05:08 -07:00
Ariel Mashraki
c259aee24b
entc/gen: generate sql builders with dialect option
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/130
Reviewed By: alexsn
Differential Revision: D18164397
fbshipit-source-id: 2858d69d3ff85c06b51382c01c3d4369ee2c3bdb
2019-10-27 21:53:50 -07:00
Alex Snast
4d835b6d6f
ent/entc: mask reserved names on type validation
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/111
Reviewed By: a8m
Differential Revision: D18037667
fbshipit-source-id: 391b4d1826bb453fc6235363fb288c2ef1d3134c
2019-10-21 07:42:45 -07:00
Alex Snast
9d9e121dbd
ent/entc: .String() now uses ansic time format when formating time fields
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/103
Reviewed By: a8m
Differential Revision: D17978059
fbshipit-source-id: 721014b0bf712943d721c7ff038239cff690b94e
2019-10-17 04:36:04 -07: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
a6df15101f
dialect/sql: fix bad query generation on clone
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/97
Reviewed By: alexsn
Differential Revision: D17931134
fbshipit-source-id: e181e253f6e29b757f5ca647195d87d7ac89a0c8
2019-10-15 13:38:39 -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
Hylke Visser
aa23f95b3e
Restore ids declaration in query builder IDs ( #95 )
...
Summary:
This pull request restores a line in the query builder template that I believe was [removed by accident](0c46ce4e5e (diff-855ebdbcdbdd5bf91fcb98886276275eL203) ).
Pull Request resolved: https://github.com/facebookincubator/ent/pull/95
Differential Revision: D17931801
Pulled By: a8m
fbshipit-source-id: d88f3f303329e2581bfa69668316f9cf5f5f0fe7
2019-10-15 09:52:09 -07:00
Ariel Mashraki
0c46ce4e5e
entc/gen: move multistorage logic to Go code
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/94
Reviewed By: alexsn
Differential Revision: D17926186
fbshipit-source-id: b59dc418703bc4faca5230a7354edea1423b7d35
2019-10-15 06:42:44 -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
Ariel Mashraki
2c8d7fcc8b
ent/doc: add custom predicate exmaple
...
Reviewed By: alexsn
Differential Revision: D17926144
fbshipit-source-id: 5390585bf634aecfad86a729db6e633c4a7e6f5e
2019-10-15 06:42:44 -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
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
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
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
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
Hylke Visser
6a1c9e73fe
entc/sql/decode: fix decoding of NullTime in optional and nillable time fields ( #60 )
...
Summary:
While trying out this project I think I found a bug in the generated code when using an optional and nillable time field.
```
vet: ent/user.go:46:16: cannot use &vu.DeletedAt (value of type *sql.NullTime) as *time.Time value in assignment
```
7438104b5d made a change to the `{{ $scan }}` struct, which now always uses `{{ $f.NullType }}` as type, so the `$f.IsTime` check can now be removed. This pull request does that.
This is my fist contribution here. I hope I didn't miss anything.
Pull Request resolved: https://github.com/facebookincubator/ent/pull/60
Differential Revision: D17760925
Pulled By: a8m
fbshipit-source-id: 675005be62487b1b9eb77302b8185bd3b6ef0195
2019-10-04 03:38:45 -07:00
Ariel Mashraki
eb240579ca
ent/gen: fix identifiers conflict in ent.tmpl
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/58
Reviewed By: alexsn
Differential Revision: D17759261
fbshipit-source-id: df7f5344b43157a483662d9ee5cf8441943b637a
2019-10-03 23:54:11 -07:00
Ariel Mashraki
8e66691db5
entc: return ErrNotFound on UpdateOne
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/52
Reviewed By: alexsn
Differential Revision: D17737477
fbshipit-source-id: 13890619e0af28a28e3d7bd50d7e4287599eeaf0
2019-10-03 06:25:11 -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
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
bf913111fd
entc: improve numeric addition api
...
Reviewed By: alexsn
Differential Revision: D17474547
fbshipit-source-id: 08e367793faac76eb0cece880259a49a8bcbc95b
2019-09-19 05:00:11 -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
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
7dfe3c174c
sql/schema: more precise blob definition
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/29
Reviewed By: alexsn
Differential Revision: D17284406
fbshipit-source-id: 84c2ffb50b8f016ad361f1420c5352c7969cbc77
2019-09-10 12:40:37 -07:00
Ariel Mashraki
d820361a3a
entc/gen: add inc/dec capability for numeric fields
...
Reviewed By: alexsn
Differential Revision: D17259987
fbshipit-source-id: ad5ba1ba7383418463bc9137d82f16eadef809e7
2019-09-10 06:00:34 -07:00
Ariel Mashraki
b067d5d8b4
dialect/sql: increment and decrement columns using "add"
...
Summary:
Use case:
```
query, args := Update("data_packs").
Add("bytes_left", count).
Where(expr...).
Query()
```
Reviewed By: alexsn
Differential Revision: D17257590
fbshipit-source-id: f27b4b388a711a16deb0c3b790e24957e044204d
2019-09-09 05:50:59 -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