Commit Graph

129 Commits

Author SHA1 Message Date
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
6bb834612c dialect/sql/schema: drop unique constraint on pg migration
Fixes #235
2019-12-15 18:52:05 +02:00
Ariel Mashraki
802e3b583a entc/integration: run tests with migrate options 2019-12-15 15:03:24 +02:00
Ariel Mashraki
e85b10be36 entc/gen: remove multi storage support 2019-12-15 14:48:55 +02: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Ariel Mashraki
38fcf995d0 entc/integration/migrate: enable postgres 10,11 in migrate test
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/132

Reviewed By: alexsn

Differential Revision: D18203398

fbshipit-source-id: a261ed3934d2e4262d7177b41546b2239e798ef5
2019-10-29 10:16:50 -07:00
Ariel Mashraki
440a737d73 entc/integration: add postgress 10,11 for test cases
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/131

Reviewed By: alexsn

Differential Revision: D18199300

fbshipit-source-id: 2335f81ba67055934dddae22ec02f1bfb43162d0
2019-10-29 03:31:14 -07:00
Ariel Mashraki
c259aee24b entc/gen: generate sql builders with dialect option
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/130

Reviewed By: alexsn

Differential Revision: D18164397

fbshipit-source-id: 2858d69d3ff85c06b51382c01c3d4369ee2c3bdb
2019-10-27 21:53:50 -07:00
Ariel Mashraki
21a58e94a3 entc/integration: test postgres schema creation
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/124

Reviewed By: alexsn

Differential Revision: D18117662

fbshipit-source-id: e8151f92e00f565db26f17f78ff46b132c46e425
2019-10-24 10:49:47 -07:00
Ariel Mashraki
e493574c83 entc: add postgres dialect for sql storage driver options
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/123

Reviewed By: alexsn

Differential Revision: D18117641

fbshipit-source-id: 8e520a1b1f70c7bea70f8a37ac698116e98a804e
2019-10-24 10:49:47 -07:00
Alex Snast
a5b1805da3 ent/entc: rename time mixin fields (#109)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/109

- created_at -> create_time
- updated_at -> update_time

Reviewed By: a8m

Differential Revision: D18035896

fbshipit-source-id: ec9aef703c444554eb0f65a668703a1a6607b93e
2019-10-22 03:45:52 -07:00
Alex Snast
4d835b6d6f ent/entc: mask reserved names on type validation
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/111

Reviewed By: a8m

Differential Revision: D18037667

fbshipit-source-id: 391b4d1826bb453fc6235363fb288c2ef1d3134c
2019-10-21 07:42:45 -07:00
Alex Snast
9d9e121dbd ent/entc: .String() now uses ansic time format when formating time fields
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/103

Reviewed By: a8m

Differential Revision: D17978059

fbshipit-source-id: 721014b0bf712943d721c7ff038239cff690b94e
2019-10-17 04:36:04 -07:00
Ariel Mashraki
a6df15101f dialect/sql: fix bad query generation on clone
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/97

Reviewed By: alexsn

Differential Revision: D17931134

fbshipit-source-id: e181e253f6e29b757f5ca647195d87d7ac89a0c8
2019-10-15 13:38:39 -07:00
Ariel Mashraki
c5b790043c entc: change the way we inject additional fields (#1560)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1560

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

Reviewed By: alexsn

Differential Revision: D17931147

fbshipit-source-id: 24e1d72be482cb787c557f46feeb2ed4a31dfe60
2019-10-15 12:00:46 -07:00
Alex Snast
5d988870bc ent/entc: use select/scan on id query (#1552)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1552

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

avoids complete ent load on id query

Reviewed By: a8m

Differential Revision: D17906002

fbshipit-source-id: 7749a0d7c707858eab368978a1d220b581ea6dbb
2019-10-14 23:16:14 -07:00
Ariel Mashraki
6f5f42ab3c dialect/sql: dialect based builders (#1550)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1550

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

This is still WIP and you should ignore this.

Reviewed By: alexsn

Differential Revision: D17854477

fbshipit-source-id: 2d19713c118adb31164b7a2781327e64c87db8d4
2019-10-13 07:03:11 -07:00
Alex Snast
9983309eac ent/circleci: cache / restore go modules (#86)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/86

In addition rename run.deadline golangci-lint config to run.timeout

Reviewed By: a8m

Differential Revision: D17863321

fbshipit-source-id: f863bac6499ddd3066a3ec6e9f518c0d5156f117
2019-10-12 23:52:42 -07:00
Ariel Mashraki
82f91dfcd2 examples/start: add license
Reviewed By: idoshveki

Differential Revision: D17788435

fbshipit-source-id: ae8ba70bcf84cf5e325291c45b69e8721a130bf1
2019-10-07 07:48:30 -07:00
Ido Shveki
3d0d8724b0 ent/schema: adding sensitive fields support (#75)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/75

Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1539

Supporting "Sensitive" mode for string fields.

Reviewed By: a8m

Differential Revision: D17786543

fbshipit-source-id: a4d022c1436472cb525cdd50663dd0ce23d13699
2019-10-07 07:46:28 -07:00
Ariel Mashraki
7597f07912 entc: add option to use entc as package
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/72

Reviewed By: alexsn

Differential Revision: D17783580

fbshipit-source-id: 597f124a28415fef66b0b16811ad2acac8df631d
2019-10-07 07:06:32 -07:00
Alex Snast
ac50ea81d4 ent: address several lint errors throughout the project (#1534)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1534

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

lint errors detected by running `golangci-lint` tool.

Reviewed By: a8m

Differential Revision: D17784980

fbshipit-source-id: f7e8bd99fdf1e018d5672cea1e8d44b67f2a4201
2019-10-06 23:59:12 -07:00
Ariel Mashraki
766940563f ent/gen: set currect storage-key for indexes
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/66

Reviewed By: alexsn

Differential Revision: D17779042

fbshipit-source-id: 12be885b20f91eb611a41e361650f7a66747fab0
2019-10-05 11:03:05 -07:00
Alex Snast
5c93cb823c ent/circleci: store go tests metadata (#63)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/63

Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1527

See https://circleci.com/blog/level-up-go-test-with-gotestsum/ for more info

Reviewed By: a8m

Differential Revision: D17761305

fbshipit-source-id: d16050b4e1825e8c23be5cc0a4b0dff80936b86a
2019-10-05 10:15:47 -07:00
Alex Snast
d581e01bb6 ent/circleci: drop goimports installation
Reviewed By: a8m

Differential Revision: D17761242

fbshipit-source-id: 7ebf67b59eed722ac329b5ab6a152140a013c64c
2019-10-05 10:15:47 -07:00
Hylke Visser
6a1c9e73fe entc/sql/decode: fix decoding of NullTime in optional and nillable time fields (#60)
Summary:
While trying out this project I think I found a bug in the generated code when using an optional and nillable time field.

```
vet: ent/user.go:46:16: cannot use &vu.DeletedAt (value of type *sql.NullTime) as *time.Time value in assignment
```

7438104b5d made a change to the `{{ $scan }}` struct, which now always uses `{{ $f.NullType }}` as type, so the `$f.IsTime` check can now be removed. This pull request does that.

This is my fist contribution here. I hope I didn't miss anything.
Pull Request resolved: https://github.com/facebookincubator/ent/pull/60

Differential Revision: D17760925

Pulled By: a8m

fbshipit-source-id: 675005be62487b1b9eb77302b8185bd3b6ef0195
2019-10-04 03:38:45 -07:00