Commit Graph

26 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
b64330e475 ent/gen: remove redundant nillable check
Summary: nillable must be optional

Reviewed By: alexsn

Differential Revision: D17763004

fbshipit-source-id: 9c134e1648d1a387d90a5f2353de855a1aa3464f
2019-10-05 11:03:05 -07:00
Ariel Mashraki
8e66691db5 entc: return ErrNotFound on UpdateOne
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/52

Reviewed By: alexsn

Differential Revision: D17737477

fbshipit-source-id: 13890619e0af28a28e3d7bd50d7e4287599eeaf0
2019-10-03 06:25:11 -07:00
Ariel Mashraki
1750d33bd8 all: add support for running examples in playground
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/49

Reviewed By: alexsn

Differential Revision: D17735758

fbshipit-source-id: d4b80631e56870690cc54912528c9950f4e48ccc
2019-10-03 03:05:40 -07:00
Ariel Mashraki
cb1f78f233 entc/gen: add open func for creating client
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/44

Reviewed By: alexsn

Differential Revision: D17657719

fbshipit-source-id: 9bbe18dc0e9c553f8a2df81018d7db06f38f5e0e
2019-10-02 01:41:40 -07:00
Alex Snast
dacc568413 ent/entc: corrently reference default value on migrate generation
Summary:
Migration incorrectly generated field default value on storage key inclusion.

Example Field:
```
field.String("tenant").
  StorageKey("organization").
  Default("fb-test"),
```
Generated default of:
```
// DefaultTenant holds the default value on creation for the tenant field.
DefaultTenant = descTenant.Default.(string)
```
But migration references non existent default (storage key is used):
```
{Name: "organization", Type: field.TypeString, Default: user.DefaultOrganization},
```

Reviewed By: a8m

Differential Revision: D17578898

fbshipit-source-id: afca92ac3f34c16100c868a10d0a480139bf4262
2019-09-25 13:51:45 -07:00
Ariel Mashraki
c3955a08f1 schema/field: json type support (#38)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/38

Only `IsNil` and `NotNil` predicates are supported this moment

Reviewed By: alexsn

Differential Revision: D17444976

fbshipit-source-id: 37336fa0bc7749af995933baee2e23bb7366dd78
2019-09-19 05:00:11 -07:00
Ariel Mashraki
83d0063437 entc/gen: returns affected rows in delete
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1455

Reviewed By: alexsn

Differential Revision: D17396880

fbshipit-source-id: 3a3a9849b816777bd0ef94cf55b2291705a37df6
2019-09-16 08:47:42 -07:00
Ariel Mashraki
3fcaf80ca4 entc/migrate: add an option to dump schema changes
Reviewed By: alexsn

Differential Revision: D17253145

fbshipit-source-id: 32640e60a8e149ac8774384db8e2ece29b9fec24
2019-09-08 06:28:58 -07:00
Ariel Mashraki
9ab0a28ffe entc/select: add selection api
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/27

Reviewed By: alexsn

Differential Revision: D17164536

fbshipit-source-id: f5caa80b05aff1ef8ec30d7a53256b00380d018c
2019-09-04 07:14:24 -07:00
Ariel Mashraki
5bc8568069 all: add license reference to README and add copyright headers to gencode
Reviewed By: alexsn

Differential Revision: D17119262

fbshipit-source-id: 046f095ca9432c920778db0edb2158dedb23c0a2
2019-08-30 08:46:03 -07:00
Ariel Mashraki
dc542e46ae entc/gen: add debug option to client
Summary:
It's possible to execute:
```
client.Debug().T.Query().AllX(ctx)
``

Reviewed By: alexsn

Differential Revision: D17092159

fbshipit-source-id: 6d1c56e8e45cfd8e36b2700c9d450f2bd5f66a71
2019-08-28 07:23:28 -07:00
Ariel Mashraki
e7fec6f8f9 entc/gen: change verbose option to debug
Summary: Change the Verbose option to Debug

Reviewed By: alexsn

Differential Revision: D17091911

fbshipit-source-id: c5cf3e1c7f33f607076fe5c7da94e04b9f236218
2019-08-28 06:45:59 -07:00
Alex Snast
373769dfaf ent/gen: adding EqualFold predicate for string fields
Summary: Similar to `ContainsFold` predicate requires `--storage=sql` argument to be passed to entc.

Reviewed By: a8m

Differential Revision: D17074805

fbshipit-source-id: ced299154417fe2c9007cd6a7a504f53c8b2ef98
2019-08-27 10:48:53 -07:00
Ariel Mashraki
bd07c86b60 all: add license header to all go files
Summary:
Used addlicense to generate this:
 addlicense -c "Facebook Inc" -f license_header .

example was taken from: https://github.com/facebook/litho/blob/master/lib/soloader/BUCK

Reviewed By: alexsn

Differential Revision: D17070152

fbshipit-source-id: e7b91398d7f6181727be3400c1872ad5f28e38ed
2019-08-27 04:48:28 -07:00
Ariel Mashraki
4c3951d53b ent/doc: m2m relation example
Reviewed By: alexsn

Differential Revision: D17050405

fbshipit-source-id: 85c41c92b15979b7aac8a6278a480cd593272f8a
2019-08-26 05:13:39 -07:00