721 Commits

Author SHA1 Message Date
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
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
Emmanuel T Odeke
9904bcb8c8 all: add (*testing.B).ReportAllocs() to all benchmarks (#1919)
This allows a full picture when continuous benchmarking
is added to this repository and when any changes are made
to the code in here.

Fixes #1918
2021-09-07 17:04:07 +03:00
Ariel Mashraki
368a8f7a2e entc/gen: replace bindata with package embed 2021-08-21 17:13:44 +03:00
Ariel Mashraki
11843ff867 go: upgrade to 1.17 2021-08-21 00:14:22 +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
Ciaran Liedeman
bab709001c entc/gen: fix panics during initTemplates when Config.Storage is nil (#1769) 2021-07-26 21:49:07 +03:00
Ariel Mashraki
8973af9b40 schema/field: add support for setting update default funcs to numeric fields (#1770)
* schema/field:add UpdateDefault to numeric (#1718)

* schema/field:fix comment

* schema/field: change interface to self type with DefaultFunc/UpdateDefault

* schema/field: change interface to self type with DefaultFunc/UpdateDefault

* schema/field: change interface to self type with DefaultFunc/UpdateDefault

* schema/field: add support for setting update default funcs to numeric fields

Co-authored-by: godcong <jumbycc@163.com>
2021-07-26 13:17:16 +03:00
Tarrence van As
cdfa3e35bb entc/gen: add Exec and ExecX to Create builder (#1753) 2021-07-23 15:00:47 +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