Commit Graph

538 Commits

Author SHA1 Message Date
MasseElch
4e434b2b73 gen/template: allow overriding of client struct and initialization (#2503) 2022-04-28 09:07:44 +02:00
MasseElch
2c8e58ce94 entc/gen: skip Table() predicate and warn about reserved schema name (Client) (#2486)
* entc/gen: do no generate `Table()` predicate and warn the user in case of reserved schema name like `Client`.

* doc/md: document reserved schema name

* doc/md: revert reserved schema name as this was already working

* doc/md: rephrase
2022-04-20 16:30:59 +02: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
Giau. Tran Minh
196875c761 entc/gen: block Optional on ID fields (#2443)
* entc/gen: block Optional on the ID field

* chore: restore the old error message

* Update entc/gen/type.go

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

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-04-02 21:01:38 +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
48bb70f056 entc/gen: allow adding extra fields to the generated edges (#2437) 2022-03-29 14:54:16 +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
Ariel Mashraki
a7c1df2d0a entc/gen: move selectbuilder scan functions to shared struct (#2412) 2022-03-18 07:59:04 +02:00
Ariel Mashraki
c071898395 entc/gen: move column default quoting to template (#2406) 2022-03-16 13:41:19 +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
Ariel Mashraki
0c7679e571 entc/gen: set Ref and Inverse for edge contains both From and To 2022-03-08 22:28:50 +02:00
Ariel Mashraki
fe2511fc8d dialect/entsql: add support for index-type annotation 2022-02-22 16:24:30 +02:00
MasseElch
d80f7cc41a entc/gen: singularize feature flag name for versioned migrations (#2350) 2022-02-21 20:06:32 +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
MrParano1d
a75e9c5a8f entc/gen: fix missing unique field in query builder template (#2332)
* fix(query): fix missing unique field in query builder template

when a query gets cloned the unique field doesn't get cloned

#2331

* fix(query): added missing go generate ./...

#2331

* fix(query): added missing go generate ./...

#2331
2022-02-15 22:31:05 +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
770e4d24e9 entc/gen: add Type.IsInt64 helper function for fields 2022-02-04 22:46:17 +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
Ariel Mashraki
94499bd141 dialect/entsql: add support for DESC indexes annotation 2022-01-31 15:18:09 +02:00
Ariel Mashraki
898991ac79 entc/gen: set foreign-key columns non-nullable for required edges (#1703)
Note, this only applies to edges without circular references.
Fixed #1688 and #1374
2022-01-23 22:23:37 +02:00
Nicholas Anderson
896f2b202d entc/gen: update NotSingularError godoc (#2274)
* fix: update only/onlyID comments

this patch updates the Only/OnlyID methods in the builder template from:

> // Returns a *NotSingularError when exactly one {{ $.Name }} entity is not found.
to
> // Returns a *NotSingularError when more than exactly one {{ $.Name }} ID is found.

in an effort to be more explicit in the explanation of the behavior of the methods.

* fix: update wording to be more concise from suggestion

Co-authored-by: Rotem Tamir <rotemtamir@gmail.com>

* fix: update Only wording to be more concicse

* fix: generate new files

Co-authored-by: Rotem Tamir <rotemtamir@gmail.com>
2022-01-23 19:07:10 +02:00
Clarence
eca70b8490 schema/field: array types are nillable (#2266)
* all: type fixes

* schema/field: remove array check from goType
2022-01-13 13:39:11 +02:00
Genevieve
16e57a92c5 entc/gen: spelling fix in error message (#2262) 2022-01-13 12:51:37 +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
Sasha Melentyev
f5fed28782 all: fix typos (#2243)
* refactor(all): Fix typo and small refactor

* refactor(all): Fix typo
2022-01-05 16:10:28 +02:00
MasseElch
84ca961938 entc/gen: there was a typo in Ty interfaces (#2251) 2022-01-05 16:09:48 +02:00
MasseElch
76770e8a52 entc/gen: don't rely on descriptor when retrieving enum values or names to ease extension testibility (#2211)
Trying to add tests to some extensions and this is complicating things a lot because `Field.def` is unexported. Not taking the length of `def.Enums` but `Enums` directly fixes this. It technically is also more correct, because `f.Enums` could be greater than `f.def.Enums`.
2021-12-11 14:25:02 +02:00
Ariel Mashraki
fd3b29f785 entc/gen: import gen.Config documentation (#2189) 2021-12-01 14:41:55 +02:00
Ariel Mashraki
6372263b99 entc/gen: add support for subtracting values from unsgined fields (#2169) 2021-11-25 12:37:43 +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
caa673826a entc/gen/mutation: add IDs method for mutations 2021-11-03 23:16:56 +02:00
Alexander Melentyev
147b1f59ae all: small typo fixes (#2095) 2021-11-01 17:47:06 +02:00
Ariel Mashraki
51b63c17c0 entc/gen: fix module version extraction when running entc as a package 2021-10-29 09:13:16 +03:00
Ariel Mashraki
909d24cfc4 entc/gen: support merging dep annotations
This will make it possible to get dependencies
from external extensions.
2021-10-28 11:08:05 +03:00
Ariel Mashraki
82eeeb5a1c entc/gen: introduce the entc.Dependency option 2021-10-26 20:33:04 +03:00
Ariel Mashraki
e687246f7a schema/field: support default values for json and other 2021-10-21 22:57:04 +03: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
mook
076e1269e8 entc/gen: fix example code in comment (#2025) 2021-10-12 10:29:58 +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
87e2199309 entc/integration: add example for bytes id with custom comparable Go type 2021-09-29 18:31:01 +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
625e422a08 entc/gen: fix bug with enum separators
Fixed https://github.com/ent/ent/issues/1961
2021-09-24 00:03:59 +03:00
Ariel Mashraki
4c2faf2282 entc/gen: allow spaces in enum fields 2021-09-23 23:23:28 +03:00