Commit Graph

173 Commits

Author SHA1 Message Date
Giau. Tran Minh
195be2d98d entc/gen: fixed unnamed field initialization (#2648)
* entc/gen: fixed ConstraintError fields name

* fix: run go generate

* entc/gen: fixed Filter fields name

* fix: run go generate again for entql
2022-06-14 12:32:46 +03:00
Giau. Tran Minh
0917701f91 entc/gen: fix wrong UserDefined checks in templates (#2572) 2022-05-28 12:12:57 +03:00
Ariel Mashraki
e1c5277483 ent: initial support for edge schemas (#2560) 2022-05-25 15:46:00 +03:00
MasseElch
51f293fc54 entc/gen/template/sql/feature: add comment to feature field on config… (#2515)
* entc/gen/template/sql/feature: add comment to feature field on config and remove blank line

* all: go generate
2022-05-02 14:29:53 +03:00
Ariel Mashraki
4cf6dd75ec entc/gen: expose config on generated filters (#2473) 2022-04-14 20:00:52 +03:00
Ariel Mashraki
89c339209e entc/gen: add the sql/execquery feature flag (#2447) 2022-04-06 13:34:22 +03:00
Ariel Mashraki
05246cbd26 gen/entc/template: add option to process nodes after query using external templates (#2444) 2022-04-02 22:01:28 +03:00
Ariel Mashraki
345d3d1783 dialect/sql: support for order by expressions in window functions (#2442) 2022-04-01 21:31:00 +03:00
Ariel Mashraki
edd968490e entc/gen: use join for loading m2m relationship (#2417)
* entc/gen: use join for m2m relationship

* entc/gen: add test for eager-load inverse-m2m
2022-03-21 11:37:54 +02:00
MasseElch
2853afc1dc dialect/sql/schema: add method to create a named versioned migration … (#2385)
* dialect/sql/schema: add method to create a named versioned migration file

* doc/md: documentation for named versioned migrations

* entc/gen/template/dialect/sql/feature: add NamedDiff method to create named versioned migration files

* all: go generate

* doc/md: apply CR
2022-03-10 16:40:57 +01:00
MasseElch
0239daca7b dialect/sql/schema: versioned migrations (#2337)
* dialect/sql/schema: fix go doc

* all: update atlas

* dialect/sql/schema: diff connected DB and defined schema and write changes to migration file

* dialect/sql/schema: use migration directory and formatter directly instead of a planner

* all: update atlas

* cmd: add command to create a new migration file

* entc/gen: generate main.go with migrate diff example

* all: regenerate

* cmd/internal/base: make linter happy

* all: support Go 1.16 in versioned migrations main.go

* entc/gen: put versioned migrations behind feature flag

* all: regenerate

* cmd/ent: driver-prefixed dsn in migrate diff command

* cmd/internal/base: remove prefix from migrate import

* cmd/internal/base: use cobra.CheckErr

* cmd: remove diff command

* entc/gen/template/dialect/sql/feature: remove generated main.go

* all: rebase on master and go mod tidy

* all: regenerate
2022-02-21 12:15:17 +02:00
Pedro Henrique
24a7e78d49 entc/gen: skip assertion on edges with type Other (#2335) 2022-02-18 00:37:16 +02:00
Pedro Henrique
f45d29ba4b entc/gen: allow if field to use field.Other with custom types (#2309)
* fix ID with field.Other comparing with zero

* fix lint

* Update entc/integration/customid/ent/schema/other.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* re-generate code

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-02-10 16:17:16 +02:00
Ariel Mashraki
1d3f1819ae entc/gen: replace Type.Alias with Type.PackageAlias 2022-02-04 22:46:17 +02:00
Ariel Mashraki
0e49dd1d9f entc/gen: support local package names for generated packages
The new Alias option adds package aliases (local names) for all type-packages that
their import identifier conflicts with user-defined packages (i.e. GoType).
2022-02-02 15:50:00 +02:00
Roman Maklakov
84070a0f07 entc/gen: add ctx in client.BeginTx (#2260)
* doc: fix docker-compose up command(#2253)

* entc/gen: add ctx in TxBegin & run go generate (#2253)

* entc/integration: add tests for TxBegin Commit and Rollback (#2253)

* entc/integration: uncomment accidentally commented code(#2253)

* entc/integration: fixes after code-review (#2253)

* entc/integration: remove blank lines, code-review (#2253)

* examples: run code gen  (#2253)
2022-01-12 14:28:55 +02:00
Andy Day
b1e76d1a05 entc/gen: fix entql generation for ID types of Bytes, etc. (#2157)
* Fix entql generation for ID types of Bytes, etc.

I was running into an issue trying to use a Bytes fieldas the ID field in a Schema, and it appears there is an currently an issue with using a Bytes field as the ID field in the entql codegen (it was outputing a function . I belive this should fix it (I tested this by adding the entql flag to the custom id integration test). I wasn't sure if the other cases I added (e.g. an ID field that is json type / time type / etc.) are actually sane ID field types, but if those don't make any sense I can remove some of those from the added conditionals.

* remove redundant line
2021-11-24 13:53:45 +02:00
Ariel Mashraki
ab207c499a entc/gen: minor codegen improvements 2021-11-08 15:56:15 +02:00
Ariel Mashraki
e915765f3b entc/gen: allow scanning nil valuescanner types directly from database
Fixed https://github.com/ent/ent/issues/2116
2021-11-07 23:09:02 +02:00
Ariel Mashraki
aa8d2ecb58 entc/gen/integ: add example for using query modifiers in multischema mode 2021-10-18 18:52:44 +03:00
Ariel Mashraki
3e6c40886d entc/gen: support count with field selection
Fixed https://github.com/ent/ent/issues/2036
2021-10-17 19:03:49 +03:00
Ariel Mashraki
9e809635b2 entc/gen: ignore immutable fields on Upsert<T>.UpdateNewValues
Also, for some reason, the TimeMixin.UpdateTime was an immutable field,
but this was incorrent, because the codegen just skip generating
update setters to it. Removing the Immutable modifier allows users
to set this field explicitly.
2021-10-08 08:20:05 +03:00
Ariel Mashraki
4306643d16 dialect/sql/sqlgraph: support sql.Scanner types when scanning IDs (#1987)
Fixed https://github.com/ent/ent/issues/1985
2021-09-27 17:49:57 +03:00
Ariel Mashraki
ac05c1357e examples: run codegen for examples 2021-09-21 20:25:08 +03:00
Lining Guan
f42014f019 enable distinct in sqlQuery 2021-09-18 16:01:11 +08:00
Ariel Mashraki
5f31091dcd entc/gen: support de/incrementing values on upsert
Fixed https://github.com/ent/ent/issues/1952.
2021-09-17 14:25:34 +03:00
Tarrence van As
f903c3a371 entc/gen: fix fk handling for bytes (#1947) 2021-09-14 22:42:48 +03:00
Ariel Mashraki
c1fae17b6c entc/gen: add schema type to generated validation errors 2021-09-07 18:33:32 +03:00
Ariel Mashraki
b8532f87a6 entc/gen: support for upsert with client generated ids
Fixed #1826
2021-08-14 17:44:04 +03:00
Ariel Mashraki
09c4306378 entc/gen: add support for upsert/on-conflict feature-flag 2021-08-04 14:01:31 +03:00
Ariel Mashraki
3307dd5323 entc/gen: add the Exec(X) methods for BulkCreate 2021-07-29 17:50:51 +03:00
Ariel Mashraki
60a544bb9d doc/featureflag: add doc and example to the sql/modifier flag 2021-07-29 11:34:21 +03:00
Neel Modi
051f19a997 entc/gen: fix typo in templates (#1760)
* fix typo

* fix typo
2021-07-22 12:19:39 +03:00
Ariel Mashraki
6a7b3c8e7a entc/gen: add feature-flag and implementation for sql/lock
Fixed #358
2021-07-21 11:50:06 +03:00
Tarrence van As
dfc7a79f6d schema/field: support unique bytes (#1720) 2021-07-20 10:24:38 +03:00
Ariel Mashraki
d3a0b89864 entc/gen: simplify the way to get gen.Field operation
External templates should not deal with storage configuration
2021-06-27 11:07:38 +03:00
Ariel Mashraki
ded20a0e36 entc/gen: cleanup sql templates 2021-06-27 10:27:10 +03:00
Ariel Mashraki
c40ae45aee entc/gen: add support for summing custom Go numeric types 2021-06-25 17:30:17 +03:00
Matthew Gabeler-Lee
110073c982 entc/gen: fix nil dereference (SIGSEGV) on db errors during Save with Hooks (#1629)
* entc/gen: check for errors before assuming success when save has hooks

* entc/integration,examples: update generated code
2021-06-09 08:56:11 +03:00
Ariel Mashraki
f5c284787f dialect/sql: allow appending select columns to query 2021-06-01 11:50:16 +03:00
Ariel Mashraki
11567a3926 entc/gen: update mutation-id on post mutation 2021-05-31 20:31:51 +03:00
Ciaran Liedeman
844f63015d entc/gen: remove internal rollback function from templates (#1602) 2021-05-26 20:17:12 +03:00
Ariel Mashraki
497fca4c96 entc/gen: skip selecting group-by fields if they already selected 2021-04-19 17:20:44 +03:00
Ariel Mashraki
a51c50f6a3 entc/gen: allow group-by by relations 2021-04-19 14:28:40 +03:00
Ariel Mashraki
2480b5c0ef entc/gen: wrap nillable fields with custom go-type with sql.nullscanner 2021-04-17 13:13:40 +03:00
Ciaran Liedeman
eff6552989 entc/gen: allow users to alter Query initialization using templates (#1453)
* Templating: Allow user to alter Query struct init

* Update entc/gen/template/dialect/sql/query.tmpl

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* pr feedback

* renamed template

* changed sql to *

* to tabs

* removed old template

* update bin-data

* Update entc/integration/template/ent/template/query.tmpl

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* restore newline

* update bindata

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-04-14 14:04:29 +03:00
Ariel Mashraki
34aabc0eb1 entc/gen/template: add goland-annotation for template data-types 2021-04-09 17:53:04 +03:00
Ariel Mashraki
2cc1c628dc schema/field: use actual go type in generated interfaces (#1428) 2021-04-07 09:53:44 +03:00
Ariel Mashraki
21989f4aa4 entc/gen: chagne column-check error format 2021-03-29 15:29:45 +03:00
Ariel Mashraki
f12ef91829 entc/gen: privatize table columns check 2021-03-29 14:35:38 +03:00