Commit Graph

344 Commits

Author SHA1 Message Date
Ariel Mashraki
f86e39f179 dialect/sql/sqlgraph: update nodes using predicate
Currently, only fields and own-FK.
Next PR will edge types: M2M, O2M and O2O (non-inverse).
2019-12-10 17:17:35 +02:00
Ariel Mashraki
75c70bac1b Merge pull request #225 from facebookincubator/examples/regen
examples: regenerate assets
2019-12-09 09:14:55 +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
f65cf5150e dialect/sqlscan: add interface{} scanning support
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/223

Reviewed By: alexsn

Differential Revision: D18878581

fbshipit-source-id: 4a60ceea6c092f065e52e6b3bb625487451a815d
2019-12-08 21:59:53 -08:00
Ariel Mashraki
0fb33aaa5e dialect/sql/sqlgraph: add update node api
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/222

Reviewed By: alexsn

Differential Revision: D18833733

fbshipit-source-id: e833d84f4e5e5c73b1c85e7387472c9a87b7947e
2019-12-08 21:59:53 -08:00
Ariel Mashraki
bb051603ac dialect/sqlgraph: add edges in node creation (#216)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/216

WIP - ignore for now

Reviewed By: alexsn

Differential Revision: D18795361

fbshipit-source-id: d3a4ef5562be5faf0837cad6364130ec203a9d37
2019-12-04 09:44:50 -08:00
Ariel Mashraki
a5e4a9cf54 dialect/sqlscan: add ScanInt64 to be used by sqlgraph
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/213

Reviewed By: alexsn

Differential Revision: D18763694

fbshipit-source-id: 890b35fcc2a28914b276ce65477788b4ddaeebf9
2019-12-03 01:44:48 -08:00
Ariel Mashraki
a4fac2db3b dialect/sqlgraph: initial work for create-node api (#211)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/211

Move out the logic from the Go templates to Go code.

Next diff will add the edges of the node.

Reviewed By: alexsn

Differential Revision: D18762049

fbshipit-source-id: c9a93672415a26a6f4a7d466e569b8b0e8b0f9ee
2019-12-02 08:12:13 -08:00
Ariel Mashraki
0f4fc12cc5 dialect/sql: support recursive pointer types
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/210

Reviewed By: alexsn

Differential Revision: D18757642

fbshipit-source-id: 6dec318f68e2f14f1c7ffdf2dcd185be130b2f77
2019-12-01 05:54:52 -08:00
Ariel Mashraki
80dab06a57 dialect/sql: match column scan with sql tag
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/209

Reviewed By: alexsn

Differential Revision: D18757390

fbshipit-source-id: 534a8404a06487d90f1f4f10b1f93c774bac2e97
2019-12-01 03:21:38 -08:00
Ariel Mashraki
1a73b8cf55 entc/gen: change neighbors-with check to use sqlgraph
Reviewed By: alexsn

Differential Revision: D18729648

fbshipit-source-id: 23eb95bdb0c34c811621a819be6581e1e6fcb474
2019-12-01 02:07:55 -08:00
Ariel Mashraki
f98dbbc440 dialect/sql/schema: remove Go 1.13 string features
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/207

Reviewed By: xjtian

Differential Revision: D18743529

fbshipit-source-id: f6420e9ca233e0ce6f9254b4f85d1711ee4d4bfa
2019-11-28 03:16:55 -08:00
Ariel Mashraki
5610d0ade9 dialect/sqlgraph: fix neighbors check with predicates
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/206

Reviewed By: alexsn

Differential Revision: D18729641

fbshipit-source-id: a5d333132ae276691ac8c1b084bc5d2037112529
2019-11-27 23:50:00 -08:00
Ariel Mashraki
29c7b0a0d8 dialect/sql: remove Go1.13 specific features
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/205

Reviewed By: alexsn

Differential Revision: D18742422

fbshipit-source-id: 1e1996fe26787788e4c0466a58884b4fa0581353
2019-11-27 23:14:24 -08:00
Ariel Mashraki
f7ce61fc3c entc/gen: change neighbors predicate to use sqlgraph
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/204

Reviewed By: alexsn

Differential Revision: D18726911

fbshipit-source-id: 6fe850bb0c0613c3f1c94e8bbcf3f0684dded9a6
2019-11-27 11:28:26 -08:00
Ariel Mashraki
5fe9fcdc1b entc/gen: fix update ids check bug in user-defined-ids
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/203

Reviewed By: alexsn

Differential Revision: D18725824

fbshipit-source-id: 888686bb5fa87649be89ec1926cbd7a3b6cf7932
2019-11-27 06:20:44 -08:00
Ariel Mashraki
ed3747ff82 entc/gen: change neighbors query to use Step builder
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/202

Reviewed By: alexsn

Differential Revision: D18725770

fbshipit-source-id: d7720ac89f55022a7721edc7df15fab1d6e3672c
2019-11-27 06:20:43 -08:00
Ariel Mashraki
0e73d57571 entc/gen: change client neighbors to use Step builder
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/201

Reviewed By: alexsn

Differential Revision: D18725715

fbshipit-source-id: 6292ac659c4d86610e39476a373dee92f2820d8d
2019-11-27 03:13:52 -08:00
Ariel Mashraki
6fe565f059 dialect/sqlgraph: add builder with functional options for neighbors steps
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/199

Reviewed By: alexsn

Differential Revision: D18707950

fbshipit-source-id: 77e5308dc4f984306c131d8541cbbd60d82a1488
2019-11-26 12:42:47 -08:00
Ariel Mashraki
413bbad8d8 dialect/sqlgraph: fix M2O relation in neighbors-with check
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/198

Reviewed By: alexsn

Differential Revision: D18707741

fbshipit-source-id: 69dd010e27ee07ffe44acc12003b9772220aaa2a
2019-11-26 12:42:47 -08: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
Ariel Mashraki
0b4f707bb9 entc/gen: add support for additional template for type package
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/196

Reviewed By: aharonnovo

Differential Revision: D18706080

fbshipit-source-id: 17293350f628c9bec234fa5ad6a6239617fa6ef3
2019-11-26 03:49:17 -08:00
Ariel Mashraki
be307dab3c dialect/sql: type alias txoptions
Reviewed By: alexsn

Differential Revision: D18689199

fbshipit-source-id: 7606a3a24beb286d464b64eb2e51a1257fbffdcd
2019-11-25 10:13:59 -08:00
Ariel Mashraki
1bf83dd65f dialect/sql: add BeginTx for sql driver
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/193

Reviewed By: dlvhdr

Differential Revision: D18685934

fbshipit-source-id: abc4bf0b14ece3827bc20ecb864e7ca0594c2759
2019-11-25 07:29:52 -08:00
Ariel Mashraki
d2fb1b5548 dialect/sql: override RETURNING clause on postgres
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/192

Reviewed By: dlvhdr

Differential Revision: D18685852

fbshipit-source-id: 90ddd1057a7d6cfa00470a7b11fb237862edcc2b
2019-11-25 07:29:52 -08:00
Ariel Mashraki
038dc2899a dialect/sqlgraph: test and fix M2M neighbors check
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/190

Reviewed By: alexsn

Differential Revision: D18680440

fbshipit-source-id: b2dce0ee3e0a898fab901c4287c6c1c1844e51d6
2019-11-24 22:34:28 -08:00
Ariel Mashraki
0344904a4e cmd/entc: support custom target on codegen (#189)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/189

Fixes #61

Reviewed By: alexsn

Differential Revision: D18676988

fbshipit-source-id: 00d415e14d1278a45edea49c69abe4916303f55d
2019-11-24 08:06:08 -08:00
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