Commit Graph

72 Commits

Author SHA1 Message Date
Ariel Mashraki
a8dde5e0d1 dialect/sql/sqlgraph: move fields setters to method calls (#2995) 2022-10-08 20:08:22 +03:00
Ariel Mashraki
13bf27bdd6 entc/gen: support Append<F> for JSON array fields (#2975) 2022-09-29 16:57:54 +03:00
Ariel Mashraki
2969796669 dialect/sql/sqlgraph: support batch-upadte for edge-schemas (#2897) 2022-09-02 15:33:41 +03:00
Ariel Mashraki
2c63d1d70e all: gofmt -w -r 'interface{} -> any' (#2874) 2022-08-19 18:23:04 +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
26e07c90c0 dialect/sql/sqlgraph: support edgeschema in entgql (#2817) 2022-08-01 18:18:12 +03: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
Ariel Mashraki
8c55008a9d dialect/sql/sqlgraph: handle edge schema in batch inserts (#2718) 2022-07-05 14:15:31 +03:00
Ariel Mashraki
ed783dba70 dialect/sql/sqlgraph: support edge-schema in upsert (#2714) 2022-07-03 23:29:35 +03:00
Ariel Mashraki
abefaa7f24 entc/gen: catch constraint failures in delete operations (#2664) 2022-06-19 14:34:32 +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
Ariel Mashraki
412947d274 dialect/sql: avoid passing bool arguments on bool predicates (#2405) 2022-03-15 22:52:49 +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
Ariel Mashraki
8f88f58713 dialect/sql/sqlgraph: minor refactor changes 2021-11-07 14:01:54 +02:00
Ariel Mashraki
02203c3f91 dialect/sqltest: ensure predicates can be reused 2021-11-02 23:01:11 +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
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
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
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
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
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
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
Ariel Mashraki
ea67be12a4 dialect/sql/sqlgraph: avoid creating tx blocks for single statement create operation
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:

	(2000 Inserts)   8.41s      4206748 ns/op    4595 B/op    115 allocs/op

To:

	(2000 Inserts)   4.66s      2330222 ns/op    4107 B/op    104 allocs/op
2021-08-20 21:12:24 +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
e71ccc6b6e dialect/sql/sqlgraph: fix bug in entql predicate evaluation (#1827) 2021-08-11 21:03:52 +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
16c4b3379b sqlgraph: change modifiers to onconflict options 2021-08-01 18:43:59 +03:00
Ariel Mashraki
7acf2234b6 dialect/sql/sqlgraph: allow setting stmt modifiers for create-many 2021-07-29 16:33:26 +03:00
Ariel Mashraki
b9fcbff724 dialect/sql/sqlgraph: allow setting stmt modifiers for create-one 2021-07-29 16:33:26 +03:00
Ariel Mashraki
279d6c2a12 dialect/sql/sqlgraph: add support for query modifiers 2021-07-20 13:14:39 +03:00
Ariel Mashraki
b46a6f0d69 dialect/sql/sqlgraph: prefix entql idents with table/select name (#1592) 2021-05-23 18:12:16 +03:00
Ariel Mashraki
edf473e043 dialect/sql: correct alias names for multiple join tables 2021-04-29 23:05:28 +03:00
Ariel Mashraki
712b6a5f08 dialect/sql/sqlgraph: allow update single node without select 2021-04-14 21:54:27 +03:00
Ariel Mashraki
56a0cf1e8b dialect/sql/sqlgraph: fix incorrect arg-list handling in entql
Fixed #1376
2021-03-22 20:27:12 +02:00
Rotem Tamir
36e3492718 dialect/sql/sqlgraph: adding unit tests for IsConstraintError (#1318)
* dialect/sql/sqlgraph: adding unit tests for IsConstraintError group of checks in second phase of #1310

* renaming test for loop variable names

* use backtick strings to improve readability
2021-03-10 18:23:24 +02:00
Rotem Tamir
2a17dba983 dialect/sql/sqlgraph: add constraint error checks (#1316)
Initial work on #1310
2021-03-09 15:56:47 +02:00
Matthew Gabeler-Lee
c53b45ddb0 all: use %w instead of %v to wrap errors (#1275)
* all: use %w instead of %v for nested errors with fmt.Errorf

* all: update generated code to use %w instead of %v for error wrapping
2021-03-03 20:05:33 +02:00
Ariel Mashraki
8a8bfe7de6 dialect/sql/sqlgraph: skip setting last-insert-id if was provided (#1291)
Fixed #1290. Issue in BulkCreate(<T>) for m2m edges
2021-03-02 11:59:20 +02:00
Ariel Mashraki
dd4792f5b3 go: rename module from github.com/facebook/ent => entgo.io/ent (#1226) 2021-02-02 23:03:04 +02:00
Ariel Mashraki
2c7228c23f dialect/sql/sqlgraph: add schema for deletion command 2021-01-24 19:57:28 +02:00
Ariel Mashraki
aeb1ccc571 entc/gen: move schemaconfig template to feature-flag 2021-01-24 19:57:28 +02:00
Ariel Mashraki
f315801779 dialect/sql/sqlgraph: apply predicate on update-node 2021-01-22 23:04:09 +02:00
Marwan Sulaiman
3439ca207f dialect/sql/sqlgraph: pass context.Context to *sql.Selector (#1186)
* Ensure sqlgraph passes the context to *sql.Selector

* Update dialect/sql/sqlgraph/graph_test.go

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

* Update dialect/sql/sqlgraph/graph_test.go

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

* gofmt

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-01-18 19:41:59 +02:00
Marwan Sulaiman
13b61ff455 dialect/sql/sqlgraph: schema options for operations (#1136)
* Add schema options for sql graph

* PR Fixes
2021-01-12 09:29:01 +02:00
Ciaran Liedeman
4a1ac1eef1 dialect/sql/sqlgraph: allow arbitrary last insert id type (#1104) 2020-12-31 12:54:44 +02:00
Ariel Mashraki
da34571560 entc/gen: allow selecting specific fields (#1075) 2020-12-23 17:35:39 +02:00
Ariel Mashraki
43fa0ae9bc dialect/sql/sqlgraph: skip empty updates (#1043) 2020-12-14 10:16:21 +02:00
Nathaniel Peiffer
42fa731f39 all: fix linting errors for comments (#990)
* fix: linting errors for comments

* fix: one more comment
2020-11-27 07:02:18 +02:00