Commit Graph

390 Commits

Author SHA1 Message Date
Ariel Mashraki
35a098fdbb dialect/sql/schema: fix bug in atlas integration when working WithDropIndex/WithDropColumn (#2374)
* dialect/sql/schema: fix no change condition in atlas

* dialect/sql/schema: fix bug in atlas integration when working WithDropIndex/WithDropColumn

Co-authored-by: Zeev Manilovich <zeevmanilovich@gmail.com>
2022-03-03 21:52:44 +02:00
Ariel Mashraki
36a1063c7e entc/integration/migrate: add FULLTEXT usage example 2022-02-22 16:24:30 +02:00
Ariel Mashraki
fe2511fc8d dialect/entsql: add support for index-type annotation 2022-02-22 16:24:30 +02: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
Thomas Prebble
ce9641e1ae dialect/sql/schema: support postgres geometric types (#2340) 2022-02-18 17:08:25 +02:00
Ariel Mashraki
51663407cf dialect/sql/schema: support DESC indexes using atlasgo.io 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
Ariel Mashraki
60e03285d0 dialect/sql/schema: hello ariga.io/atlas (#2279) 2022-01-20 17:20:50 +02:00
Ariel Mashraki
b70754d12f dialect/sql/sqlgraph: avoid creating tx blocks for single statement batch-create operation (#2272)
For example, in PostgreSQL, every statement is executed within a transaction. Therefore, we can avoid creating transaction
blocks manually (group of statements surrounded by BEGIN and COMMIT) for CreateNode operation with single SQL statement.

Benchmark was improved from:

	(4000 BatchInserts)    17.16s      4289178 ns/op  412893 B/op   4913 allocs/op

To:

	(4000 BatchInserts)   9.16s      2288807 ns/op  412142 B/op   4899 allocs/op
2022-01-15 23:04:37 +02:00
s-takehana
0fd6143979 dialect/sql/schema: support time with time zone and time without time zone (#2257)
* dialect/sql/schema: support `time with time zone` and `time without time zone`

* fix test

* fix test
2022-01-12 14:33:26 +02:00
Ariel Mashraki
6848f3fc7b dialect/sql/schema: do not sort primary-key columns before diff (#2254)
PKs are indexes and therefore, the order does matter.
Thanks to ariga.io/atlas we found this issue.
2022-01-09 15:37:21 +02:00
Ariel Mashraki
deb63d0292 dialect/sql: support passing selectors to basic predicates
Closed https://github.com/ent/ent/issues/2236
2021-12-25 15:02:49 +02:00
Mehmet Yılmaz
4d01a56b8d dialect/sql/schema: allow adding DEFAULT to columns on migration #1758 (#2199)
* add feature to SET DEFAULT value when add new default value to a existing column

* refactoring unit tests

* correct misspells

* code review refactors

* refactors

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-12-20 11:29:07 +02:00
Mehmet Yılmaz
8a6ff230c8 dialect/sql/schema: convert column type string to lower case (#2222)
Fixed #2209

* convert column type string to lower case

* Update dialect/sql/schema/sqlite.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-12-19 21:02:06 +02:00
Ariel Mashraki
1c263c7abd dialect/sql: add support for SelectExpr (#2220) 2021-12-16 13:50:03 +02:00
Yoni Davidson
b8149f2768 dialect/schema: support float for mysql on inspection (#2191)
* dialect/schema: support float for mysql

* add tests
2021-12-07 12:45:46 +02:00
Ariel Mashraki
475e237937 dialect/sql/schema: fix bug when using multiple table CHECK constraints (#2188)
Fixed https://github.com/ent/ent/issues/2185
2021-12-01 12:00:06 +02:00
Naor Matania
8847a1ac55 dialect/sql/schema: fix migrating Postgres fields with max character varchar custom type (#2162)
* Support migration of varying length varchar postgres

* update type

* fix type

* improve type

* remove not needed change

* fix failing test

* add inspect test

* add more tests

* go fmt

* fix pr comment
2021-11-28 07:57:57 +02:00
Ariel Mashraki
b99ce66f40 dialect/sql: calling Update.Add after Update.Set should append expression (#2168) 2021-11-25 12:03:12 +02:00
Ariel Mashraki
6402fc7fe2 Merge pull request #2137 from ent/getoutreach-grevych/sqljson-pattern-matching-predicates
Getoutreach grevych/sqljson pattern matching predicates
2021-11-16 10:21:08 +02:00
Ariel Mashraki
77701d4db6 dialect/sql/sqljson: use the builtin string predciates in sqljson and improve tests 2021-11-16 10:07:34 +02:00
Ariel Mashraki
a5fea077a9 dialect/sql: use identifier qualifiers for WHERE clause on upsert
Fixed https://github.com/ent/ent/issues/2126
2021-11-12 23:46:46 +02:00
Ariel Mashraki
0dd7b0d7c3 dialect/sql/sqljson: fix sqlite haskey and add docs 2021-11-11 18:58:28 +02:00
Ariel Mashraki
3ba2b4e173 entc/integration/json: add tests for null literals 2021-11-10 17:24:51 +02:00
Ariel Mashraki
0c5398a11d dialect/sql/sqljson: support comparing values with null literal 2021-11-10 17:24:51 +02:00
Ariel Mashraki
dd6c034c2a dialect/sql/schema: support mediumtext field in migration
Fixed https://github.com/ent/ent/issues/2113
2021-11-07 15:37:06 +02:00
Ariel Mashraki
8f88f58713 dialect/sql/sqlgraph: minor refactor changes 2021-11-07 14:01:54 +02:00
Ariel Mashraki
e8e4401d27 dialect/sqltest: use postgres dialect in predicate tests 2021-11-03 13:39:39 +02:00
Ariel Mashraki
02203c3f91 dialect/sqltest: ensure predicates can be reused 2021-11-02 23:01:11 +02:00
Alexander Melentyev
147b1f59ae all: small typo fixes (#2095) 2021-11-01 17:47:06 +02:00
Andrey Elenskiy
62d64f2b78 dialect/sql/sqlgraph: use selector's column instead of table's column in HasNeighbors (#2060)
Allows for HasNeighbors' selector to be a generic selector instead of *SelectTable.
A use case for this is doing HasNeighbors* function on materialized queries instead
of on concrete tables only.
2021-10-25 07:46:54 +03:00
Ariel Mashraki
a1f6de2793 dialect/sql: escape special characters in pattern matching
Resources:
- https://www.postgresql.org/docs/current/functions-matching.html\#FUNCTIONS-LIKE
- https://www.sqlite.org/lang_expr.html\#the_like_glob_regexp_and_match_operators
- https://dev.mysql.com/doc/refman/8.0/en/string-literals.html

Fixed https://github.com/ent/ent/issues/2059
2021-10-24 21:14:26 +03:00
Ariel Mashraki
963bd669fd dialect/sql: add example to SIMILAR TO predicate (#2055) 2021-10-21 12:01:58 +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
899e9f0e50 dialect/sql: wraps the sql.Rows with ColumnScanner interface 2021-10-14 09:32:30 +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
f30a17edd4 all: fix linting issues before migrating to golangci v1.42 (#2019) 2021-10-07 19:54:43 +03:00
Shen Yang
65cf307b10 dialect/sql/schema: add support for tstzrange and interval and in postgres (#2013)
Fixes #1989
2021-10-06 21:46:34 +03:00
Ariel Mashraki
14cba0abb6 dialect/sql/schema: make Field.Unique and Index.Unique equal (#2004)
This will allow moving from:

	field.String(c).Unique()

To:

	index.Field(c).Unique()

And vice versa
2021-10-03 16:20:28 +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
4c2faf2282 entc/gen: allow spaces in enum fields 2021-09-23 23:23:28 +03:00
storyicon
779594f7da dialect/sql/schema: support mysql mediumtext type (#1972)
Signed-off-by: storyicon <yuanchao@bilibili.com>
2021-09-22 15:35:14 +03:00
Ariel Mashraki
5c7c36bf29 dialect/sql/schema: skip parsing expression default for postgres
Fixed https://github.com/ent/ent/issues/1962
2021-09-21 15:59:04 +03: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
Ariel Mashraki
912415e1e1 dialect/sql: add Add method to UpdateSet 2021-09-16 23:41:29 +03:00
Ariel Mashraki
3c650e507e dialect/sql: use raw 0 in COALESCE function on Add calls
The second argument for COALESCE function is not a dynamic argument (always 0).
2021-09-16 23:07:45 +03:00
Ariel Mashraki
38925b6134 dialect/sql/schema: revert #1547 for mariadb 2021-09-14 13:07:49 +03:00
Ariel Mashraki
0864659844 dialect/sql/sqlgraph: avoid creating tx blocks for single UPDATE statements
In PostgreSQL, every statement is executed within a transaction. Therefore, we can avoid
creating transaction blocks manually (group of statements surrounded by BEGIN and COMMIT)
for UpdateNodes operation with a single UPDATE statement.

Benchmark for 2000 operations was improved from:

	7.98s      3992160 ns/op    4887 B/op    116 allocs/op

To:

	4.42s      2209659 ns/op    4435 B/op    104 allocs/op

---

MySQL and SQLite share the same behavior. Please see #1858 for more info.
2021-09-11 08:56:37 +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
b23a0e8554 dialect/sql/sqlgraph: avoid creating tx blocks for single DELETE statements
In PostgreSQL, every statement is executed within a transaction. Therefore, we can avoid
creating transaction blocks manually (group of statements surrounded by BEGIN and COMMIT)
for DeleteNodes operation as it's implemented with a single statement.

Benchmark for 4000 operations was improved from:

	14.54s      7270455 ns/op    3702 B/op     81 allocs/op

To:

	5.36s      2679935 ns/op    2864 B/op     59 allocs/op

---

MySQL and SQLite share the same behavior. Please see https://github.com/ent/ent/pull/1858
for more info.
2021-08-27 16:02:29 +03:00