Commit Graph

32 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Ariel Mashraki
da34571560 entc/gen: allow selecting specific fields (#1075) 2020-12-23 17:35:39 +02:00
Ariel Mashraki
e775227a11 dialect/sql/sqlgraph: avoid query on update when it's not needed (#932)
Closed #909
2020-11-10 10:01:40 +02:00
Alex Snast
cd0a79e821 sql/builder: expand limit / offset into query instead of args (#816) 2020-10-04 13:13:56 +03:00
Ariel Mashraki
fc03257412 dialect/sql: add an option for clearing m2m edges (#730) 2020-09-06 17:27:31 +03:00
Ariel Mashraki
b18716931d dialect/sql: change boolean operators wrapping (#678)
The reason is to parentheses only when it's necessary.
2020-08-20 10:08:31 +03:00
Ariel Mashraki
fd0a7f9f02 all: facebookincubator/ent => facebook/ent (#660)
ent repository is going to be migrated to facebook organization
2020-08-18 11:05:08 +03:00
Ariel Mashraki
720766432a dialect/sql/sqlgraph: initial work for batch insert (#573)
This is the first part for adding batch insert support for the framework.
The second part if the codegen.
2020-07-08 17:48:26 +03:00
Ariel Mashraki
b93958ebf4 dialect/sql/sqlgraph: add query edges function (#274) 2020-01-07 19:50:33 +02:00
Ariel Mashraki
c09028f58b dialect/sql/sqlgraph: consistent scan names 2019-12-22 20:12:00 +02:00
Ariel Mashraki
a26b9626a6 entc/gen: move query-count to sqlgraph 2019-12-22 19:42:28 +02:00
Ariel Mashraki
7fde9b7642 entc/gen: move sql-update-one to sqlgraph 2019-12-22 13:32:51 +02:00
Ariel Mashraki
0cc74b5297 all: move sqlgraph to its own package 2019-12-17 18:26:09 +02:00