aca
3ee6223e64
entc/gen: use empty slice instead of nil in sqlAll ( #310 )
2020-01-23 16:16:21 +02:00
Harold.Luo
5cb40ff883
entc/gen/eagerloading: ignore loading edges on empty result ( #298 )
...
* fix eagerloading
while parent nodes is zero.
* Update entc/gen/template/dialect/sql/query.tmpl
Co-Authored-By: Ariel Mashraki <7413593+a8m@users.noreply.github.com >
* Update entc/gen/template/dialect/sql/query.tmpl
Co-Authored-By: Ariel Mashraki <7413593+a8m@users.noreply.github.com >
* generate new assets
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com >
2020-01-20 09:29:01 -05:00
Ariel Mashraki
9b2b53f559
entc/gen: avoid conflict local vars with user packages ( #292 )
...
Fixes #284
2020-01-16 17:30:18 +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
e5c5aec9b5
entc/gen: remove FromRows decoding
2019-12-24 10:29:40 +02:00
Ariel Mashraki
7a85c04c32
entc/gen: add edge-fields + minor changes
2019-12-23 10:57:36 +02:00
Ariel Mashraki
91cdd2a087
entc/gen: remove unnecessary subquery on fields selection
2019-12-22 20:24:29 +02:00
Ariel Mashraki
c09028f58b
dialect/sql/sqlgraph: consistent scan names
2019-12-22 20:12:00 +02:00
Ariel Mashraki
6f9dade32c
entc/gen: move query-all to sqlgraph
2019-12-22 20:00:25 +02:00
Ariel Mashraki
a26b9626a6
entc/gen: move query-count to sqlgraph
2019-12-22 19:42:28 +02:00
Ariel Mashraki
1c54439d40
entc/gen: move scan-assign to node def
2019-12-22 17:15:33 +02:00
Ariel Mashraki
7fde9b7642
entc/gen: move sql-update-one to sqlgraph
2019-12-22 13:32:51 +02:00
Ariel Mashraki
04e9391c25
entc/gen: move sql-delete to sqlgraph
2019-12-18 15:14:53 +02:00
Ariel Mashraki
798d58f02b
all: use more go-ish error for constraint failures
2019-12-17 23:17:55 +02:00
Ariel Mashraki
c6800a3869
entc/gen: move node creation to sqlgraph
2019-12-17 22:45:04 +02:00
Ariel Mashraki
0cc74b5297
all: move sqlgraph to its own package
2019-12-17 18:26:09 +02:00
Ariel Mashraki
e85b10be36
entc/gen: remove multi storage support
2019-12-15 14:48:55 +02:00
Ariel Mashraki
1a73b8cf55
entc/gen: change neighbors-with check to use sqlgraph
...
Reviewed By: alexsn
Differential Revision: D18729648
fbshipit-source-id: 23eb95bdb0c34c811621a819be6581e1e6fcb474
2019-12-01 02:07:55 -08:00
Ariel Mashraki
f7ce61fc3c
entc/gen: change neighbors predicate to use sqlgraph
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/204
Reviewed By: alexsn
Differential Revision: D18726911
fbshipit-source-id: 6fe850bb0c0613c3f1c94e8bbcf3f0684dded9a6
2019-11-27 11:28:26 -08:00
Ariel Mashraki
5fe9fcdc1b
entc/gen: fix update ids check bug in user-defined-ids
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/203
Reviewed By: alexsn
Differential Revision: D18725824
fbshipit-source-id: 888686bb5fa87649be89ec1926cbd7a3b6cf7932
2019-11-27 06:20:44 -08:00
Ariel Mashraki
ed3747ff82
entc/gen: change neighbors query to use Step builder
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/202
Reviewed By: alexsn
Differential Revision: D18725770
fbshipit-source-id: d7720ac89f55022a7721edc7df15fab1d6e3672c
2019-11-27 06:20:43 -08:00
Ariel Mashraki
0e73d57571
entc/gen: change client neighbors to use Step builder
...
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/201
Reviewed By: alexsn
Differential Revision: D18725715
fbshipit-source-id: 6292ac659c4d86610e39476a373dee92f2820d8d
2019-11-27 03:13:52 -08: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Alex Snast
85b29631a8
entc/schema: adding support for immutable fields ( #1340 )
...
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1340
Immutable fields are ent fields which cannot be updated
Reviewed By: a8m
Differential Revision: D16899625
fbshipit-source-id: ca482c66570e84ca9a1e0a03f729847561f2816b
2019-08-20 02:17:13 -07:00
Ariel Mashraki
7438104b5d
entc/sql/decode: use null types for fields scanning
...
Reviewed By: alexsn
Differential Revision: D16890638
fbshipit-source-id: bfe3699831875a559d322a500ffc20a976f30a44
2019-08-19 05:02:37 -07:00
Ariel Mashraki
619b63d5f7
ent/schema: rename nullable to nillable
...
Reviewed By: idoshveki
Differential Revision: D16687892
fbshipit-source-id: e8cfaaf1241e94c2de0a9fe9077326339d593716
2019-08-07 06:56:33 -07:00
Ariel Mashraki
25f5a2ef01
entc/predicate: add isnull/notnull predicates for codegen
...
Reviewed By: idoshveki
Differential Revision: D16687226
fbshipit-source-id: 14a39e066447dbf77413e5c7f7318a2d61bddd32
2019-08-07 06:56:32 -07:00
Ariel Mashraki
2fd1b728f3
ent: add AND operator for type predicates
...
Reviewed By: alexsn
Differential Revision: D16668249
fbshipit-source-id: 1554c3af9779fd551a90218c604d23b5bf8b8c6b
2019-08-06 14:41:56 -07:00