Commit Graph

483 Commits

Author SHA1 Message Date
Ariel Mashraki
cfb038810d dialect/sql/entsql: support including non-key columns in postgres indexes (#2912) 2022-09-07 22:09:48 +03:00
Giau. Tran Minh
2cdb627c0d dialect/sql/sqljson: quote non-identifiers (#2910)
* dialect/sql: fixed invalid json path quote

* fix: fixed empty string

* fix: fixed lint issue

* Apply suggestions from code review

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

* fix: added test to new case

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-09-07 14:49:11 +03:00
Ariel Mashraki
1773fc465e dialect/sql: add support for statement prefix in update builder (#2904) 2022-09-06 17:34:53 +03:00
Ariel Mashraki
2969796669 dialect/sql/sqlgraph: support batch-upadte for edge-schemas (#2897) 2022-09-02 15:33:41 +03:00
Abirdcfly
3b1b75b9d7 dialect/sql/sqljson: remove duplicate word in comments (#2892)
Signed-off-by: Abirdcfly <fp544037857@gmail.com>

Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-08-30 10:19:04 +03:00
Ryo Yamada
015effdcc1 dialect/sql/builder: added FullJoin (#2885)
* dialect/sql/builder: added FullJoin

* fix comment casing

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

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-08-30 07:39:35 +03:00
Ariel Mashraki
bedbea6665 dialct/sql/sqljson: fix HasKey implementation for SQLite (#2887) 2022-08-29 23:37:30 +03:00
Ariel Mashraki
79fe0ebcd6 sql/sqljson: add support for ValueIn/ValueNotIn (#2882) 2022-08-24 17:58:44 +03:00
Ariel Mashraki
2c63d1d70e all: gofmt -w -r 'interface{} -> any' (#2874) 2022-08-19 18:23:04 +03:00
Jannik Clausen
b6c185a660 dialect/sql/schema: make use of new atlas migration directories and r… (#2873)
* dialect/sql/schema: make use of new atlas migration directories and remove examples for custom formatters

* typo
2022-08-19 14:42:54 +02:00
Pedro Henrique
2b54aadcce dialect/sql: escape EqualFold on Postgres (#2860)
* adds tests for equalFold predicates

* ensure EqualFold escapes the argument on Postgres

* adds tests on builder as well
2022-08-16 10:09:06 +03:00
Ariel Mashraki
94b19ac973 dialect/sql: use raw NULL value in statements rather than passing nil arguments 2022-08-14 11:10:36 +03:00
Ariel Mashraki
0fd641333c dialect/sql/sqlgraph: support custom modifiers in UPDATE commands 2022-08-05 14:42:04 +03:00
Ariel Mashraki
9f481d8716 dialect/sql: support setting ORDER BY for UPDATE statements 2022-08-05 14:42:04 +03:00
Ariel Mashraki
26e07c90c0 dialect/sql/sqlgraph: support edgeschema in entgql (#2817) 2022-08-01 18:18:12 +03:00
Andy Day
8beaef87ba dialect/sql/builder: make sql.NotIn() with empty args fallback to NOT FALSE (#2757)
* dialect/sql/builder: make sql.NotIn() with empty args fallback to False()

This is basically the identical change to #2735, but for NotIn().

This bug currently prevents anyone using NotIn() from upgrading from v0.10.x to v0.11.x

* Update go.sum

untidy

* feedback
2022-07-19 06:36:39 +03:00
Ariel Mashraki
1c01301de1 sql/dialect/schema: support setting PK to serial types in postgres (#2748) 2022-07-13 14:40:56 +03:00
Ariel Mashraki
6c8a1308ec entc/gen: edge schema with custom ids (#2742)
Fixed https://github.com/ent/ent/issues/2740
Fixed https://github.com/ent/ent/issues/2741
2022-07-12 18:13:45 +03:00
Ryo Yamada
b00e549c88 dialect/sql: make sql.In() with empty args fallback to False() (#2735)
* dialect/sql/builder: make sql.In() with empty args fallback to False()

* fix indent

* added comment

* remove the equilvalent logic in the codegen side

* comment fix, run go generate
2022-07-12 00:15:36 +03:00
Jannik Clausen
bc623b3f64 all: update atlas (#2739) 2022-07-11 15:25:14 +02:00
Ariel Mashraki
ba582c83b3 entc/gen: improve edge-schema updates (#2726)
Also, added additional example where an edge schema has another edge
to a type that holds an information about the relationship.

The only reason this example exists is to allow users to reduce the storage
occupied by the join-table and allow connect (via M2O) multiple edge-schemas
to an 'information'/'description' node.
2022-07-07 07:34:17 +03:00
Jannik Clausen
412f5f75ca add docs about auto-increment counter "bug" in MySQL versions < 8.0 and how to handle it (#2722) 2022-07-06 10:34:39 +02:00
Ariel Mashraki
2c1a3555cc entc/gen: ignore edge-fields order in edge-schema with composite identifiers (#2719)
This PR allows defining edge schemas with any order of their edges
but still enforce the ordering of the fields in the ID annotation
2022-07-05 15:45:28 +03:00
Ariel Mashraki
8c55008a9d dialect/sql/sqlgraph: handle edge schema in batch inserts (#2718) 2022-07-05 14:15:31 +03:00
Jannik Clausen
5b67bdab4f dialect/sql/schema: atlas engine is now default (#2698)
* atlas engine is default, enabled diff by replay

* Apply suggestions from code review

* docs

* apply CR
2022-07-05 12:29:15 +02:00
Ariel Mashraki
ed783dba70 dialect/sql/sqlgraph: support edge-schema in upsert (#2714) 2022-07-03 23:29:35 +03:00
Ariel Mashraki
8416fb502d dialect/sql/schema: setup tables before running migrate diff (#2703)
Keep the same API as schema.Create
2022-06-30 09:55:40 +03:00
Hafiz Shafruddin
5dbfa24b46 doc/md: add docs on using expression predicates in custom WHERE clauses (#2520)
* Add docs on using ExprP() for custom WHERE sql statement

* Add ExprP() examples using integration test

* move custom predicate example and show examples using both P() and ExprP()

* fix to greater or equal than

* rephrase wording and fix sql builder

* Update doc/md/predicates.md

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

* Update doc/md/predicates.md

* Update doc/md/predicates.md

* Update doc/md/predicates.md

* Update doc/md/predicates.md

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-06-29 11:24:20 +03:00
Ariel Mashraki
311d760679 entc/gen: allow opening and testing concurrent enttest clients (#2665) 2022-06-20 08:32:30 +03:00
Ariel Mashraki
abefaa7f24 entc/gen: catch constraint failures in delete operations (#2664) 2022-06-19 14:34:32 +03:00
Ariel Mashraki
98d00a35b5 go: update atlas and test global-unique-id migration (#2661) 2022-06-18 21:50:44 +03:00
Jannik Clausen
7017cbc898 dialect/sql/schema: file based type store (#2644)
* dialect/sql/schema: file based type store

This PR adds support for a file based type storage when using versioned migrations. The file called `.ent_types` is written to the migration directory alongside the migration files and will be kept in sync for every migration file generation run.

In order to not break existing code, where the type storage might differ for different deployment, global unique ID mut be enabled by using a new option. This will also be raised as an error to the user when attempting to use versioned migrations and global unique ID.

Documentation will be added to this PR once feedback on the code is gathered.

* apply CR

* fix tests

* change format of types file to exclude it from atlas.sum file

* docs and drift test

* apply CR
2022-06-15 16:10:15 +02:00
Jannik Clausen
bfa9c963cb dialect/sql/schema: introduce type store interface (#2636)
This will allow us to store information about pk ranges allocated per type in a different location thant the database. This is useful for deterministic pk range computation for things like generating atlas.hcl out of the Ent schema.
2022-06-10 10:08:33 +02:00
Sasha Melentyev
dd4519f935 dialect/entsql: rename annotation vars (#2614) 2022-06-06 11:20:56 +03:00
Ariel Mashraki
5b81d7d832 dialect/sql/sqlgraph: better support for update nodes with predicates (#2574) 2022-05-29 16:23:52 +03:00
Ariel Mashraki
e1c5277483 ent: initial support for edge schemas (#2560) 2022-05-25 15:46:00 +03:00
Jannik Clausen
4142108d62 doc/website/blog: external tools and sum file (#2489)
* doc/website/blog: external tools and sum file

* Apply suggestions from code review

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

* doc/website/blog: apply CR

* Apply suggestions from code review

Co-authored-by: Hila Kashai <73284641+hilakashai@users.noreply.github.com>

* doc/website/blog: minor fixes

* doc/website/blog: invoke atlas command by calling go run

* doc/website/blog: It's-a me, Jannik!

* Apply suggestions from code review

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

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
Co-authored-by: Hila Kashai <73284641+hilakashai@users.noreply.github.com>
Co-authored-by: Rotem Tamir <rotemtamir@gmail.com>
2022-05-09 15:23:51 +02:00
Pedro Henrique
4d1c0af20d entc/integration: add examples for sub-queries + minor fixed for selector builder (#2509)
* dialect/sql: move FROM to inside switch

* dialect/sql: adds simple example of subquery usage

* dialect/sql: adds a more complex example with join

* Apply suggestions from code review

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

* dialect/sql: fix missing type and change modify to where

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-05-05 22:46:13 +03:00
MasseElch
12b6659c72 dialect/sql/schema: respect sumfile when present and do not operate on checksum mismatch (#2522) 2022-05-05 10:43:20 +02:00
Ariel Mashraki
dab95be855 doc/md: example and test for migration apply hooks (#2514) 2022-05-02 14:25:22 +03:00
MasseElch
e50d335c30 dialect/sql: support string based pk for mysql56 indexes (prevent err… (#2506)
* dialect/sql: support string based pk for mysql56 indexes (prevent error 1071)

* Update entc/integration/customid/ent/schema/revision.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-29 08:57:22 +02:00
MasseElch
4db0c544c2 dialect/sql: add New method to pass in a river without opening a *sql.DB before (#2504) 2022-04-28 13:12:34 +02:00
MasseElch
c1175719a2 dialect/sql/schema: option to enable atlas sum file (#2470)
* dialect/sql/schema: option to enable atlas checksum file

* entc/integration/migrate: add integration tests for versioned migrations

* entc/integration/migrate: apply CR
2022-04-13 21:36:57 +02:00
MasseElch
89dc83887c doc/md: document usage of atlas supported migration tools (#2467)
* doc/md: document usage of atlas supported migration tools

* dialect/sql/schema: fix tests
2022-04-13 12:47:00 +02:00
Ariel Mashraki
6e4e4da896 entc/integration/migrate: update atlas and test custom time precision (#2462) 2022-04-08 11:27:30 +03:00
Carlos González
5dd5acc08d dialect/sql: fixed a small typo in docs (#2459) 2022-04-07 19:54:43 +03:00
Ariel Mashraki
89c339209e entc/gen: add the sql/execquery feature flag (#2447) 2022-04-06 13:34:22 +03:00
Charles Ge
e463cbca55 init db version before executing diff (#2440)
What's the problem: Under versioned migration on MySQL 8.0, unique string field would be generated as type varchar(191) instead of varchar(255). This is because in generating migration files by NamedDiff(), sqlDialect's init() method is not called. 

Further concern: For init() function, MySQL and Postgres's implementation checks the database version which is what I want. But SQLite's implementation checks the foreign_keys support. So I think there might be a better may to check the database version before doing Diff().
2022-04-06 09:43:13 +02: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
317594ec80 dialect/sql/schema: prefix sqlite unique indexes with table name (#2433)
Fixed https://github.com/ent/ent/issues/2421
2022-03-28 12:54:39 +03:00