Commit Graph

316 Commits

Author SHA1 Message Date
Ariel Mashraki
67c3fd2db9 entc/gen: initial work for supporting uuid fields in codegen
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/182

Reviewed By: alexsn

Differential Revision: D18638199

fbshipit-source-id: 0de79c78b51e544486c07a004c3c8ea82e5c3398
2019-11-24 07:11:23 -08:00
Ariel Mashraki
e6c6442c84 cmd/entc: load package path for arbitrary file paths (#186)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/186

This is an ongoing work for fixing #61 (Github issue)

Reviewed By: alexsn

Differential Revision: D18672982

fbshipit-source-id: 12051d7b06d87d73d37b68382566732e532193e3
2019-11-24 07:11:23 -08:00
Ariel Mashraki
d2fe7199e5 entc/load: return packages.Load error when 'go list' fails (#187)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/187

Also, remove the dependency of pkg/errors from load package.

Reviewed By: alexsn

Differential Revision: D18672979

fbshipit-source-id: 88a881a99e93896f8d3a0aefcf61fbd995b7fa08
2019-11-24 07:11:22 -08:00
Ariel Mashraki
7fb6238d18 dialect/sql: add hasneighborswith for predicates
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/185

Reviewed By: alexsn

Differential Revision: D18661688

fbshipit-source-id: 4c60fa5e81372f10bfecf4f166b048784bc515ee
2019-11-24 07:11:22 -08:00
Ariel Mashraki
0fc310e600 sql/dialect/schema: ignore foreign-keys in index dropping
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/188

Reviewed By: alexsn

Differential Revision: D18676877

fbshipit-source-id: 0babe457edadfa46dcbc7c7478d4468c48f84361
2019-11-24 05:32:22 -08:00
Ariel Mashraki
2543d90167 dialect/sql: add hasneigbors for predicates (#184)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/184

This diff is part of the ongoing effort for moving the sql logic out from codegen.

Reviewed By: alexsn

Differential Revision: D18656817

fbshipit-source-id: 71001d37eb78032414c2f83f200d3011b50c114b
2019-11-24 04:16:36 -08:00
Ariel Mashraki
c355ed49be entc/gen: move set-neighbors logic from codegen to sqlgraph
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/183

Reviewed By: alexsn

Differential Revision: D18644179

fbshipit-source-id: 2f2b0c03811a09c4c11240e5161187afbb2ac553
2019-11-24 04:16:36 -08:00
Ariel Mashraki
1e49561634 ent: support external uuid types (#181)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/181

The lack of generic typing requires to check the function type in the "loading" phase of the schema.

Reviewed By: alexsn

Differential Revision: D18636969

fbshipit-source-id: d8229779bf3c2490e51f5d0d4c550c70e2cd2550
2019-11-21 08:49:59 -08:00
Ariel Mashraki
e54373f410 ent: allow non-numeric columns as PKs
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/180

Reviewed By: alexsn

Differential Revision: D18636443

fbshipit-source-id: f14b34926817f6d9652f49a640bfb377f3f3cdaf
2019-11-21 08:49:58 -08:00
Ariel Mashraki
bc4284cf2c ent/gen: trim invalid tokens in identifier prefix
Reviewed By: alexsn

Differential Revision: D18636356

fbshipit-source-id: f5ea4b4d003ec09d1351782e7691e9e657d15ed6
2019-11-21 08:49:58 -08:00
Alex Snast
b34c955739 ent/entc: adding NonNegative predicate to signed int types
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/179

Reviewed By: a8m

Differential Revision: D18617566

fbshipit-source-id: ab5ced97836d05ee5936b39f571063cf618b3481
2019-11-20 10:11:58 -08:00
Ariel Mashraki
703a6dd039 dialect/sql/schema: mysql support for uuid type
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/176

Reviewed By: alexsn

Differential Revision: D18615992

fbshipit-source-id: 2c86a661e8d75165470b9b2d351cb973147290d8
2019-11-20 09:49:55 -08:00
Ariel Mashraki
f7dac21972 dialect/sql/schema: sqlite support for uuid type
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/177

Reviewed By: alexsn

Differential Revision: D18615595

fbshipit-source-id: b3167a0aa9260cdf22d88dd7e45c7ebfae1909d5
2019-11-20 09:49:55 -08:00
Ariel Mashraki
db7b05ad04 dialect/sql/schema: postgres support for uuid type
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/178

Reviewed By: alexsn

Differential Revision: D18615561

fbshipit-source-id: 8244189186bf35d78cfdb991ee4f8cecd6411cee
2019-11-20 09:49:54 -08:00
Ariel Mashraki
33d08673cf schema/field: initial work for UUID fields
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/175

Reviewed By: idoshveki

Differential Revision: D18614288

fbshipit-source-id: d36e6dc6e7745e982cf91bb4c4548dcd3d9d33ac
2019-11-20 07:14:40 -08:00
Ariel Mashraki
49c8efce3c schema/field: fix type jsons -> json
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/173

Reviewed By: idoshveki

Differential Revision: D18614200

fbshipit-source-id: d4da2da3e150a83b12f7404672bbbad1f46aad22
2019-11-20 07:14:40 -08:00
Ariel Mashraki
7be1779ad1 entc/gen: add the type name as an index prefix (#171)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/171

Note that this is a non backwards compatible change.

I'll add another change (before this) for setting the storage-key of the index, and only after that we can land this.

Reviewed By: alexsn

Differential Revision: D18570445

fbshipit-source-id: e3ffc7b4baa6bc2fcce9e4553e17817091423b1e
2019-11-20 07:08:47 -08:00
Ariel Mashraki
3f76e83bcf ent/circleci: set specific postgres versions (#174)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/174

Integration tests are failing with latest images.

Reviewed By: idoshveki

Differential Revision: D18614385

fbshipit-source-id: 80239c943cbef3a3cc0227f8052b2bac8f816533
2019-11-20 05:40:03 -08:00
Ariel Mashraki
3c6661fce8 schema/index: add storage-key option for indexes
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/172

Reviewed By: alexsn

Differential Revision: D18571700

fbshipit-source-id: 2b8dbcc7c36be01ba383c48f982f59361a68c621
2019-11-18 07:54:56 -08:00
Ariel Mashraki
829de26c4f entc/load: add the default value for schema fields when possible (#170)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/170

Used to verify enum default values in the genrator

Reviewed By: alexsn

Differential Revision: D18561625

fbshipit-source-id: fde153a042d2e7b6da7f7d2c5b045c93266e276f
2019-11-17 09:06:58 -08:00
Ariel Mashraki
d31f0828f0 dialect/sql: replace nulltime with official implementation on 1.13 and higher
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/169

Reviewed By: alexsn

Differential Revision: D18561431

fbshipit-source-id: d21335c073e0abed99d97c85c03cfa17c8326fef
2019-11-17 09:06:58 -08:00
Alex Snast
d1089d30a5 ent/node: wrap errors triggered by invalid ids (#68)
Summary:
Pull Request resolved: https://github.com/facebookincubator/symphony/pull/68

Pull Request resolved: https://github.com/facebookincubator/ent/pull/168

Allows masking graphql node query errors caused by invalid ids.
In addition fixing .noder() implementation to return a nil Noder on .Get error.

Reviewed By: a8m

Differential Revision: D18560549

fbshipit-source-id: a480ebacb197071b036cb4f4bee4cd9c71e6d006
2019-11-17 02:28:22 -08:00
Ariel Mashraki
2b2e056f05 entc/gen/sql: support custom-id on create
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/166

Reviewed By: alexsn

Differential Revision: D18514295

fbshipit-source-id: e5988552c5611cbad18476ab2d9c2155df1e6e0c
2019-11-14 14:38:58 -08:00
Ariel Mashraki
38002e6d2e entc/gen: use custom id type in join table (#165)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/165

Only when it's provided by the use explicitly

Reviewed By: alexsn

Differential Revision: D18506319

fbshipit-source-id: 4cc0bb2c3bbb26f8b27b12e4aa01407fb604928d
2019-11-14 09:47:35 -08:00
Ariel Mashraki
d9da7243f9 entc/gen: initial support for user-defined ids
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/162

Reviewed By: alexsn

Differential Revision: D18485086

fbshipit-source-id: 9bb6ccff592bc0cb8b218625161ed492f67bc170
2019-11-14 08:21:31 -08:00
Ariel Mashraki
e161ecc29c cmd/entc: remove graph printing from generator
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/163

Reviewed By: alexsn

Differential Revision: D18503829

fbshipit-source-id: 1269d4c8c30f848c5096258f2328230f5f378f69
2019-11-14 08:21:30 -08:00
Ariel Mashraki
54b1a2ead9 sql/dialect/schema: accept old blob types in mysql (#164)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/164

support varbinary as blob types

Reviewed By: yhayun

Differential Revision: D18504189

fbshipit-source-id: e3c8fcf412d1f6374b0084b439eee426b24b3466
2019-11-14 06:37:17 -08:00
Ariel Mashraki
8093ec4127 entc/gen: avoid using Go keywords as variables on scan
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/161

Reviewed By: alexsn

Differential Revision: D18483166

fbshipit-source-id: 7273d284232c1bf515cc84326904b580fb70a0e3
2019-11-13 11:35:58 -08:00
Ariel Mashraki
84fd066e2c entc: return an error if template was not found (#160)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/160

Code was failing due to nil pointer in case of unknown template

Reviewed By: alexsn

Differential Revision: D18477913

fbshipit-source-id: 5c93e9697c5d62cbb9a0a6955231aa133c52f6db
2019-11-13 07:27:28 -08:00
Ariel Mashraki
6ce4cb6803 all: fix minor lint errors
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/159

Reviewed By: dlvhdr

Differential Revision: D18476131

fbshipit-source-id: 9e792f5a35f25233aad73f75f12d13d215a21ad2
2019-11-13 06:01:41 -08:00
Ariel Mashraki
a4f82f2331 ent/gen: add indexes to schema modes
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/158

Reviewed By: dlvhdr

Differential Revision: D18476130

fbshipit-source-id: a2003a9a51df6712f18ec58326569c2de7c42b83
2019-11-13 05:58:32 -08:00
Ariel Mashraki
aece79f8a8 dialect/sql: add option for getting the neighbors of set of vertices (#157)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/157

It should be used by the query builders for stepping to neighbors of the matches.

Reviewed By: alexsn

Differential Revision: D18448517

fbshipit-source-id: bf3aeea8c90a4e9b090e9298a20600b8f0b5ace3
2019-11-12 10:37:23 -08:00
Alex Snast
aa57d732c1 ent/entc: correctly cache type info in node.tmpl
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/156

Reviewed By: a8m

Differential Revision: D18429543

fbshipit-source-id: 11bbd9c426878f819ebb2b89978e10948f0730bd
2019-11-12 00:13:43 -08:00
Ariel Mashraki
73e294a21e dialect/sql: reduce the number of joins on neighbors without predicates (#154)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/154

Loading the "form" table is not required where there's no predicate on the join.

Reviewed By: alexsn

Differential Revision: D18421062

fbshipit-source-id: cb2a045a5a8a76ea4f07e5cf4305a6da338a616e
2019-11-10 21:51:32 -08:00
Ariel Mashraki
514c0ff6d3 entc/gen: add support for adding client fields using template
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/155

Reviewed By: alexsn

Differential Revision: D18421223

fbshipit-source-id: 112d4d26d53a64e2c78640c6d508ba2d1d3a7791
2019-11-10 13:29:38 -08:00
Ariel Mashraki
6ed99b93e5 entc/integration: add edges-only index
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/153

Reviewed By: idoshveki

Differential Revision: D18419861

fbshipit-source-id: af7a07eacc601d0db54a5512f6edf26d725f5f7e
2019-11-10 02:56:34 -08:00
Ariel Mashraki
3ac23d8420 entc/gen: allow defining index only on edges (#152)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/152

Fixes #150

Reviewed By: idoshveki

Differential Revision: D18419810

fbshipit-source-id: aeabd9c3379d4456235884abeca01407569cd7dc
2019-11-10 02:56:34 -08:00
Alex Snast
782f3d90c9 ent/integration: refactor node template to provide .Noder on client (#50)
Summary:
Pull Request resolved: https://github.com/facebookincubator/symphony/pull/50

Pull Request resolved: https://github.com/facebookincubator/ent/pull/149

Noder can be used to implement graphql Node interface over gqlgen.

See https://facebook.github.io/relay/graphql/objectidentification.htm for more info.

Reviewed By: a8m

Differential Revision: D18410318

fbshipit-source-id: 5e9e2f243ab96ef61999f9066ffee65cb39094fe
2019-11-09 09:34:23 -08:00
Ariel Mashraki
4aa550a68f entc/gen: avoid ambiguous selector error when adding config field
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/147

Reviewed By: alexsn

Differential Revision: D18380088

fbshipit-source-id: 8173b0082b69eda4e623da618a54d443b34d20eb
2019-11-07 22:08:33 -08:00
Ariel Mashraki
0ff49fe89f dialect/sql: add neighbors test for O2O with 2 types
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/146

Reviewed By: idoshveki

Differential Revision: D18369884

fbshipit-source-id: 8cba47de27831d317dbe438ccff49b61132f6085
2019-11-07 02:42:35 -08:00
Ariel Mashraki
6eb14bba9f dialect/sql: add O2O tests for graph neighbors
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/145

Reviewed By: naor9991

Differential Revision: D18354409

fbshipit-source-id: 0327443cfb8cae6c2136cf6acc4057a17d0e3e0c
2019-11-06 23:54:31 -08:00
Ariel Mashraki
53cfcb6e8b dialect/sql: fix predicate builder on join
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/143

Reviewed By: idoshveki

Differential Revision: D18346652

fbshipit-source-id: e8c5d7eb3cefc16f52090de0d121e82cae058fc2
2019-11-06 05:21:26 -08:00
Ariel Mashraki
7a6d1ce9dc dialect/sql: add tests for graph neighbors function
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/141

Reviewed By: naor9991

Differential Revision: D18333780

fbshipit-source-id: 920f1c77182ee2a5cbd942d6c9cceec448b9900b
2019-11-05 22:50:16 -08:00
Ariel Mashraki
930a17b767 dialect/sql: add neighbors function (#140)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/140

This part of the effort of moving logic from Go templates to shared packages.
Next diffs will migrate the neighbors-set and predicates as well.

Dedicated tests for `sql/dialect/graph.go` will be added in a follow-up diff.

Reviewed By: alexsn

Differential Revision: D18304531

fbshipit-source-id: 93e9cf2636b5b4525eb27305bd2708122cfd6e40
2019-11-05 13:08:48 -08:00
Ariel Mashraki
a5d6a9e8b8 entc/integration: add missing license header
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/138

Reviewed By: alexsn

Differential Revision: D18291686

fbshipit-source-id: a1df2e4e3e036f6877acb33cbb27d05dfa982668
2019-11-03 05:54:44 -08:00
Hylke Visser
02bae0d652 Remove update validators for immutable fields (#137)
Summary:
This pull request modifies the update builder template so that it no longer generates code to validate immutable fields.

The first commit breaks the integration code by making the `number` field of `Card` immutable (the generated validation code references non-existent fields of `CardUpdate`/`CardUpdateOne`).

The second commit fixes the issue by making the `update/save` template not render validation code for immutable fields.
Pull Request resolved: https://github.com/facebookincubator/ent/pull/137

Differential Revision: D18288633

Pulled By: a8m

fbshipit-source-id: c0361b833a3971f76280d624f16cd7eda2725c1e
2019-11-02 09:05:08 -07:00
Ariel Mashraki
2d8e122226 circleci: add short-verbose option to gotessum
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/135

Reviewed By: alexsn

Differential Revision: D18247848

fbshipit-source-id: b6b774e1bae58ee705086e54415806155ba4b3b8
2019-10-31 10:16:00 -07:00
Ariel Mashraki
838b8fab8a entc/integration: move relation tests to its own file (#134)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/134

integration_test.go was too big and not fun to work with.

Reviewed By: alexsn

Differential Revision: D18246139

fbshipit-source-id: 0c4437578adb9da4b03fc737044b3b7738b0bd4a
2019-10-31 10:11:38 -07:00
Ariel Mashraki
559f163abe all: add postgres to docs
Reviewed By: alexsn

Differential Revision: D18245079

fbshipit-source-id: d4f59d88fe2125d924bfb85521fa43898ea5ce35
2019-10-31 06:31:21 -07:00
Ariel Mashraki
a9d787edf7 ent/integration: enable postgres in json tests
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/133

Reviewed By: alexsn

Differential Revision: D18227305

fbshipit-source-id: 33718041db52014f82dad831b5b609c511e0ba9a
2019-10-30 12:52:40 -07:00