Commit Graph

77 Commits

Author SHA1 Message Date
Alex Snast
66255ea86e entc/gen/privacy: adding decision context support (#462)
Decision context holds a privacy decision (i.e. allow / deny) and if
exists will be returned before any rule is evaluated.

Signed-off-by: Alex Snast <alexsn@fb.com>
2020-05-05 15:53:15 +03:00
Ariel Mashraki
7cfcb97694 entc/gen: suffix Order and Aggregate with Func (#449) 2020-04-23 13:22:21 +03:00
Alex Snast
6e584d8efc Revert "entc/gen/privacy: mask allow error on policy evaluation"
This reverts commit 8a93447fe5.
2020-04-23 10:10:41 +03:00
Alex Snast
8a93447fe5 entc/gen/privacy: mask allow error on policy evaluation
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-04-23 09:27:37 +03:00
Ariel Mashraki
b880885e9f entc/gen: group enttest imports properly (#443) 2020-04-21 00:10:05 +03:00
Alex Snast
5f180a6954 entc/gen/privacy: rename DenyMutationOperation -> DenyMutationOperationRule
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-04-20 18:57:19 +03:00
Ariel Mashraki
d3b89fb2be entc/gen: add enttest package for generated code. (#442)
* entc/gen: add enttest package for generated code.

It's still WIP and another 2 things need to be added:
- Add an option to skip schema migration and pass client options
- Update docs and replace existing testing code to use enttest

* entc/gen: finish enttest package tempalte

Signed-off-by: Alex Snast <alexsn@fb.com>

Co-authored-by: Alex Snast <alexsn@fb.com>
2020-04-20 16:37:26 +03:00
Alex Snast
0ef1b2dcff entc/gen: adding DenyMutationOperation privacy rule helper (#441)
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-04-20 14:28:00 +03:00
Ariel Mashraki
3342b85580 entc/gen: add support for storage txoptions (#435) 2020-04-17 12:57:57 +03:00
Alex Snast
1b0e5ffaf4 entc/gen: simplify hook chain creation (#424)
* entc/gen: simplify hook chain creation

Signed-off-by: Alex Snast <alexsn@fb.com>

* circleci: upgrade orb versions

Signed-off-by: Alex Snast <alexsn@fb.com>
2020-04-07 08:11:33 +03:00
Alex Snast
d52d5120fd entc/gen: adding hook chain construct (#423)
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-04-06 19:53:10 +03:00
Alex Snast
901c1394b4 entc/gen: load client bound to transaction once (#417)
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-04-02 12:22:42 +03:00
Alex Snast
d6d95dd363 entc/gen: adding tx callback support (#414)
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-03-31 18:58:10 +03:00
Alex Snast
6e6651c878 Query policy (#411)
* entc/gen: drop xerrors package usage

* all: bump dependencies version

* entc/gen: adding query privacy policy support
2020-03-29 18:11:13 +03:00
Ariel Mashraki
de5006a4d8 entc/gen: lazy compute storage-driver queries (#408) 2020-03-29 14:36:44 +03:00
Alex Snast
6be07b8f67 entc/privacy: rename Read/Write types to Query/Mutation
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-03-19 14:35:32 +02:00
Alex Snast
63c6d9786d entc/gen: adding ent.Query type
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-03-19 14:30:00 +02:00
Alex Snast
25fdb52a03 entc/gen: use a set when tracking cleared fields in mutation template
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-03-17 12:00:15 +02:00
Ariel Mashraki
81a2f60e47 entc/gen: add facebookincubator/ent to mutation.tmpl imports (#390) 2020-03-17 10:33:58 +02:00
Ariel Mashraki
7988d3084d entc/hooks: initial work for mutations and hooks (#377)
* entc/hooks: initial work for mutations and hooks

* ent/schema: adding policy to schema

* ent: change op string to uint

* entc: move entschema to runtime and enable smooth transition

* entc/privacy: adding privacy template

* all: goimports

* intg/hooks: mutation client/tx and basic schema tests

* ent/privacy: adding more verbose decisions

* entc/gen: edge-ids getter and additional tests

* all: regen assets

* entc/gen: fix client hookd propagation

* intg: add deletion example

* intg/privacy: remove old entschema package

* typed privacy

* ent/privacy: hooks shouldn't be called on privacy deny

* entc/gen: fix schema hooks invocation order

* remove read policy from public api

* update circleci go orb

Co-authored-by: Ariel Mashraki <ariel@mashraki.co.il>
2020-03-16 00:19:27 +02:00
Ariel Mashraki
332cfe5c6e entc/gen: use named fields on client creations (#359) 2020-02-25 11:15:38 +02:00
Ariel Mashraki
dc222c0b15 entc/gen: remove example_test template from codegen (#351)
Fixes #297
2020-02-18 12:26:46 +02:00
Ariel Mashraki
320b9caf61 dialect/sql/schema: add option to skip fixture when it's irrelevant (#350) 2020-02-16 18:17:58 +02:00
Ariel Mashraki
d9c8d9545d entc/gen: use NotFoundError when updating non-exist node (#348)
Fixes #341
2020-02-16 13:26:13 +02:00
Ariel Mashraki
9f9596c184 entc/gen: better formatted codegen for predicates (#336) 2020-02-09 11:38:03 +02:00
Ariel Mashraki
b4255998bf entc/gen: change name format for edge fks (#286)
* entc/gen: change name format for edge fks

* dialect/sql/schema: add fixture support for mysql and postgres

* sql/dialect: merge fkcolumn queries to one for the 2 dialects
2020-02-03 15:41:55 +02:00
Alex Snast
e6ba06441b entc/gen: change <E>Err signature to <E>OrErr (#325)
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-01-30 18:56:36 +02:00
Alex Snast
0802e0b4f5 Merge pull request #324 from facebookincubator/nil_before_as
entc/gen: check for nil error before invoking .As
2020-01-30 13:47:17 +01:00
Alex Snast
091f9aba12 entc/gen: check for nil error before invoking .As
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-01-30 13:42:13 +01:00
Alex Snast
112d442dac Merge pull request #323 from facebookincubator/errwrap
entc/gen: add support for wrapped errors
2020-01-30 10:57:08 +01:00
Alex Snast
0428788539 entc/gen: add support for wrapped errors
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-01-30 10:53:58 +01:00
Ariel Mashraki
9e760aae58 entc/gen: change <E>WithError signature to <E>Err (#322)
<E>WithError is too verbose and we like short names
2020-01-30 11:12:53 +02:00
Ariel Mashraki
27935a8c6c entc/gen: add <E>Loaded for <T>Edges (#319)
This helps to determine if the edge was loaded (or requested) in
eager-loading even if it's empty.
2020-01-29 11:39:19 +02:00
Ariel Mashraki
7a480e3943 entc/gen: use more go-ish names for generated error types (#321)
* entc/gen: use more go-ish names for generated error types

* entc/gen: add NotLodedError type for eager-load api
2020-01-28 11:04:27 +02:00
Ariel Mashraki
bc89ed4e0f entc/gen: add type for type edges (#318)
Will be used for adding methods on the struct edges
2020-01-26 12:39:18 +02:00
aca
3ee6223e64 entc/gen: use empty slice instead of nil in sqlAll (#310) 2020-01-23 16:16:21 +02:00
Ariel Mashraki
faf6c2f2f6 ci: initial work for migration-testing (#311)
Also generating new assets for new ci steps.
2020-01-22 21:20:18 +02:00
Harold.Luo
5cb40ff883 entc/gen/eagerloading: ignore loading edges on empty result (#298)
* fix eagerloading

while parent nodes is zero.

* Update entc/gen/template/dialect/sql/query.tmpl

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

* Update entc/gen/template/dialect/sql/query.tmpl

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

* generate new assets

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2020-01-20 09:29:01 -05:00
Jeremy
259bf07b5d examples: regenerate examples (#296) 2020-01-19 13:00:17 +02:00
Ariel Mashraki
caf721df47 entc/gen: add eager-loading support (#263)
* entc/gen: add OwnFK indicator for type edges

* entc/gen: add Edges field for generated types

* entc/gen: add With<T> method to query-builder template

* entc/gen: scan and assign foreign-keys on eager-loading

* entc/gen: load fk-relations (wip)

* entc/integration: add o2m/m2o tests for eager-loading

* entc/gen: add m2m support for eager-loading

* entc/gen: add integration tests for m2m and subgraphs

* entc/gen/integration: add tests for o2o eager-loading

* all: generate all assets
2020-01-13 17:21:26 +02:00
Ariel Mashraki
1f2cb87cee examples: regenerate assets
Closes #261
2019-12-25 11:21:04 +02:00
Ariel Mashraki
7fde9b7642 entc/gen: move sql-update-one to sqlgraph 2019-12-22 13:32:51 +02:00
Ariel Mashraki
04e9391c25 entc/gen: move sql-delete to sqlgraph 2019-12-18 15:14:53 +02:00
Ariel Mashraki
0a7608f8bd all: change codegen header 2019-12-18 13:00:25 +02:00
Ariel Mashraki
798d58f02b all: use more go-ish error for constraint failures 2019-12-17 23:17:55 +02:00
Ariel Mashraki
c6800a3869 entc/gen: move node creation to sqlgraph 2019-12-17 22:45:04 +02:00
Ariel Mashraki
0cc74b5297 all: move sqlgraph to its own package 2019-12-17 18:26:09 +02:00
Ariel Mashraki
ef7a1ed300 examples: make examples testable 2019-12-09 09:05:05 +02:00
Ariel Mashraki
754a8c9daa examples: regenerate assets 2019-12-09 08:13:34 +02:00
Ariel Mashraki
56335d6e12 ent: regenerate assets
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/197

Reviewed By: aharonnovo

Differential Revision: D18706251

fbshipit-source-id: 1603030671f4541f21a6b34d5ea0b8b7ccbea8da
2019-11-26 05:47:56 -08:00