Commit Graph

854 Commits

Author SHA1 Message Date
Pedro Henrique
8307c2eaba entc/gen: copies interceptors on Clone (#3194) 2022-12-28 06:29:48 +02:00
Ariel Mashraki
c868f4a174 doc: add entsql.WithComments annotation (#3192) 2022-12-26 16:56:49 +02:00
Ariel Mashraki
136807549d dialect/entsql: supports setting SQL column comments (#3191)
* feat: Add column comment in SQL DDL, using EntSQL annotations to achieve it.

* Update annotation.go

* fix lint

* Add table primary key column comment

* entsql.Comment(string)  is unnecessary

* entc/gen: minor changes to entsql.WithComments + add tests

Co-authored-by: chenghonour <wantto@outlook.com>
2022-12-26 14:48:37 +02:00
Ariel Mashraki
92bacc10e4 entc/gen: add typed traversers and interceptors (#3182) 2022-12-20 11:12:19 +02:00
Ariel Mashraki
34bd0b7b6f entc/gen: move mutation hooks logic to a shared generic function (#3180) 2022-12-19 17:36:29 +02:00
Ariel Mashraki
68a4533574 entc/gen: use new sql predicates to reduce codegen size (#3179) 2022-12-19 11:40:39 +02:00
Ariel Mashraki
f226627d67 ent: export query interceptors (#3157) 2022-12-19 10:17:10 +02:00
Andy Day
63c123f36c schema: add Comment annotation (#3164)
* Add schema.CommentAnnotation (resolves #3155)

Adds new mechanism for customizing a model's godoc comment in code (via an Annotation).

* feedback
2022-12-10 23:30:45 +02:00
Ariel Mashraki
d0c5afa705 entc/gen: make generated client to implement the ent.Mutator interface (#3161) 2022-12-09 21:18:25 +02:00
Christopher Schmitt
d7f2f3a098 entc/gen: add driver as a reserved field word (#3158) 2022-12-09 08:08:30 +02:00
Pedro Henrique
0f20a3d007 entc/integration: test with Postgres 15 (#3152) 2022-12-07 11:55:06 +02:00
Ariel Mashraki
381483e45c entc/gen: remove unnecessary sqlgraph.To step on HasE predicates (#3144)
Predicate that checks existence-only do not need the 'other' table
2022-12-04 13:15:16 +02:00
Ariel Mashraki
3f1d7c960e example: add jsonencode using extension (#3142) 2022-12-04 10:38:23 +02:00
Ariel Mashraki
f1205ce95f entc/gen: remove driver specific implementation for Exist (#3136) 2022-12-01 17:39:52 +02:00
Ariel Mashraki
b6a475f066 entc/gen: skip generating edge-schema unique indexes if defined 2022-11-23 18:56:02 +02:00
Ariel Mashraki
2d980550db doc/edges: document the new edges behavior 2022-11-20 17:37:08 +02:00
Ariel Mashraki
f46dd7ace8 dialect/sql/sqlgraph: add support for edge-schema in create-bulk 2022-11-20 17:37:08 +02:00
Ariel Mashraki
aa3d21f01a dialect/sql/sqlgraph: changing the M2M creation semantic from Add to Connect
Thus, calling AddE with the same edge values, ignore and not throw an error.
For edge-schemas with extra fields, we maintain the same logic because we cannot
determine if the extra fields have different values that what exist in the database
2022-11-20 17:37:08 +02:00
Ariel Mashraki
4dd6b5bb74 entc/gen: minor imporvements to make goimports work easier (#3106) 2022-11-18 22:54:17 +02:00
Ariel Mashraki
da9322fd2e entc/gen: remove unnecessary import from templates (#3105) 2022-11-18 21:45:48 +02:00
Ariel Mashraki
5954fa8b15 dialect/sql/schema: normalize ent/schema (desired state) on replay mode (#3100) 2022-11-16 20:01:36 +02:00
Ariel Mashraki
891fc8fecf dialect/sql/schema: support setting default value expressions on id fields (#3089) 2022-11-13 18:55:04 +02:00
Ariel Mashraki
53bdc325c0 entc/gen/schemaconfig: set alternate edge-schema names from config (#3087)
Fixed https://github.com/ent/ent/issues/3082
2022-11-12 21:42:57 +02:00
Ariel Mashraki
25021635a0 doc/fields: document default values using annotations 2022-11-12 14:38:33 +02:00
Ariel Mashraki
1e5f68646f dialect/sql/entsql: support setting expression as column default value
Fixed https://github.com/ent/ent/issues/3069
2022-11-12 14:38:33 +02:00
Ariel Mashraki
3b5a535801 dialect/sql/schema: allow setting JSON default values on pg, sqlite and maria (#3081) 2022-11-11 07:41:21 +02:00
Weilence
b0eb20f0f7 entc/gen: enable BuildFlags in *.go (#3075)
Co-authored-by: Weilence <weilence163.com>
2022-11-08 18:32:40 +02:00
Ariel Mashraki
eae7d390a9 dialect/sql: add support for index operator-class using atlasgo.io (#3073) 2022-11-08 14:08:10 +02:00
nzlov
942eb56b2a cmd/ent: add comments to 'describe' command (#3067) 2022-11-07 16:23:07 +02:00
Ariel Mashraki
a91aabe3ef entc/gen: ensure foreign-key constraints are unique in codegen (#3066) 2022-11-05 07:28:50 +02:00
Ronen Lubin
5d4f02620d dialect/sql/sqljson: add ValueIsNotNull predicate (#3058)
* dialect/sql: add json ValueIsNotNull predicate

* get rid of false positive dupl linter warning

* add json valueIsNotNull case to integration tests

* fix rejects
2022-11-02 11:18:15 +02:00
Ariel Mashraki
35d0d4c3db dialect/sql/sqlgraph: handle edge-schema in M2O/O2Oi calls entql 2022-11-01 19:46:33 +02:00
Ariel Mashraki
521f9b57bc entc/gen: copy annotations to the Through meta-edge 2022-10-31 15:55:57 +02:00
Ariel Mashraki
c063978d68 entc/gen: ensure edge.StorageKey and edge.Field do not conflict
Fixed https://github.com/ent/ent/issues/2205.
2022-10-30 00:08:44 +03:00
Ariel Mashraki
3ddcb76ba0 entc/gen: fix codegen typo 2022-10-26 21:08:39 +03:00
Ariel Mashraki
765ec09d31 entc/gen: add Aggregate to <T>Select and <T>Query 2022-10-23 09:50:23 +03:00
Ariel Mashraki
1bc4d48a51 dialect/sql: support scanning json fields (#3022) 2022-10-18 16:18:50 +03:00
Joe Wreschnig
ac725a61b7 entc: add BuildFlags to schema loader configuration (#2801)
This allows passing arbitrary build flags to the schema package loader,
which in turn can be used to pass build constraints affecting what
schema types and/or methods are visible.

As a particular use case, this should make it easier to implement
two-pass code generation to deal with circular imports in hooks (#892).
2022-10-16 16:53:47 +03:00
Ariel Mashraki
cf137c665a dialect/sql/sqljson: cast marshaled args as json (#3008) 2022-10-11 14:15:01 +03:00
Marwan Sulaiman
713828b311 Remove unused variable and type redundancy (#2996) 2022-10-09 00:59:52 +03:00
Ariel Mashraki
a8dde5e0d1 dialect/sql/sqlgraph: move fields setters to method calls (#2995) 2022-10-08 20:08:22 +03:00
Ariel Mashraki
1029a2d3ba entc/gen: attach tx hooks to underlying driver (#2980)
Allow attaching hooks to new instances of ent.Tx.
For example, ent.Mutation.Tx().OnCommit.
2022-10-01 09:26:02 +03:00
Ariel Mashraki
13bf27bdd6 entc/gen: support Append<F> for JSON array fields (#2975) 2022-09-29 16:57:54 +03:00
Ariel Mashraki
eb4ea68356 dialect/sql/sqljson: add dialect-aware Append function 2022-09-29 08:54:44 +03:00
Jannik Clausen
c41d223733 dialect/sql/schema: disable foreign keys before opening a transaction (#2966)
* dialect/sql/schema: disable foreign keys before opening a transaction

* dialect/sql/schema: disable foreign keys before opening a transaction

* fix tests

* add test for bug

* apply CR
2022-09-28 07:41:49 +02:00
Ariel Mashraki
e93e96ed1b dialect/sql/schema: use serial underlying types for fks (#2963) 2022-09-27 07:54:07 +03:00
Giau. Tran Minh
679109f5c2 entc/gen: remove space around continue for 1.18 compatible (#2962)
Related: https://github.com/golang/go/issues/51670
Signed-off-by: Giau. Tran Minh <hello@giautm.dev>

Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
2022-09-26 21:10:15 +03:00
Ariel Mashraki
3fc4ba6f15 dialect/entsql: add support for partial indexes (#2944) 2022-09-20 15:07:28 +03:00
Pedro Henrique
1f8e4ada01 entc/gen: allow package with alias on ID field (#2926)
* entc/gen: allow package with alias on ID field

* Update entc/gen/template/import.tmpl

Co-authored-by: Giau. Tran Minh <giau.tmg@gmail.com>

Co-authored-by: Giau. Tran Minh <giau.tmg@gmail.com>
2022-09-18 16:45:21 +03:00
Ariel Mashraki
ac937f8a6e entc/gen: allow using 'client' and 'tx' as schema field names (#2919) 2022-09-09 10:38:25 +03:00