Commit Graph

81 Commits

Author SHA1 Message Date
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
Ariel Mashraki
eb240579ca ent/gen: fix identifiers conflict in ent.tmpl
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/58

Reviewed By: alexsn

Differential Revision: D17759261

fbshipit-source-id: df7f5344b43157a483662d9ee5cf8441943b637a
2019-10-03 23:54:11 -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
1ebfa489c5 ent: add support for enum types
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/45

Reviewed By: alexsn

Differential Revision: D17715085

fbshipit-source-id: 7472e1bd9cf7a8a5bd98f96e6e884c0e27f36803
2019-10-02 12:55:28 -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
Ariel Mashraki
4dbebe68ff entc: add codegen support for mixin
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/43

Reviewed By: alexsn

Differential Revision: D17600868

fbshipit-source-id: 39a242a541fa2a2dd2db1c9919fecf192ff098bf
2019-09-26 07:41:11 -07:00
Alex Snast
6cf5b918c3 ent/entc: keep struct tags sorted
Summary: keeping tags sorted will prevent codegen changes due to random map key ordering

Reviewed By: a8m

Differential Revision: D17571598

fbshipit-source-id: 12afc4aa0d030aa178e6568eb7c768ccc159f726
2019-09-25 06:48:01 -07:00
Alex Snast
517d22843c ent/schema: adding .NotEmpty() helper to string field
Summary: just a wrapper around .MinLen(1) but makes it cleaner when reading the schema

Reviewed By: a8m

Differential Revision: D17551384

fbshipit-source-id: 1e2c7639eff7032f433271582830c7e11a2fb0d5
2019-09-25 00:00:42 -07:00
Ariel Mashraki
0f71ca6ad8 entc/cmd/entc: support more numeric types for ids
Reviewed By: alexsn

Differential Revision: D17527952

fbshipit-source-id: 1465b054531cee8ca1dd445b6654063f32f4c4e3
2019-09-23 09:48:24 -07:00
Ariel Mashraki
3f7553af20 entc/gen: add tag ignoring for private fields
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1487

Reviewed By: alexsn

Differential Revision: D17527793

fbshipit-source-id: b264706b8af74ff94d384dddd1b5a14661478676
2019-09-23 09:48:24 -07:00
Ariel Mashraki
76f5b6ec5f ent/schema: add config for customize schema options
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/40

Reviewed By: alexsn

Differential Revision: D17480104

fbshipit-source-id: 5223430e3b2223b8471a85bd1d85b445f23acfce
2019-09-22 01:38:07 -07:00
Ariel Mashraki
bf913111fd entc: improve numeric addition api
Reviewed By: alexsn

Differential Revision: D17474547

fbshipit-source-id: 08e367793faac76eb0cece880259a49a8bcbc95b
2019-09-19 05:00:11 -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
Alex Snast
2b1ff377b5 ent/entc: move Get / GetX operation under client
Summary: Saves typing `.Query()` every time we want to use `.Get()`

Reviewed By: a8m

Differential Revision: D17396667

fbshipit-source-id: 103c10d25bd1181b8e52fa272f2c1a26f47ed9f6
2019-09-16 07:44:41 -07:00
Ariel Mashraki
624ecd2cc7 schema/field: add storage-key option
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/35

Reviewed By: alexsn

Differential Revision: D17394930

fbshipit-source-id: bc9d8cc6569ad457b93d47d26d143f2442f98df9
2019-09-16 04:39:17 -07:00
Ariel Mashraki
78a7509c52 entc: clear optional field values
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/33

Reviewed By: noamsch

Differential Revision: D17344992

fbshipit-source-id: 5336e9c5a4978e10923e26b5754942d92371a5cd
2019-09-15 04:44:55 -07:00
Ariel Mashraki
651dc25dd1 graph/ent: add node template and codegen
Summary:
This change allows to call `Client.Node` to get node info.

```
node, err := client.Node(ctx, id)
```

Reviewed By: dlvhdr

Differential Revision: D17341682

fbshipit-source-id: bed1fe018cca7f5048a624b50b1f5cc6cc3507f3
2019-09-12 02:50:57 -07:00
Ariel Mashraki
ade72ced0d entc/integration: test external templates with node interface (#31)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/31

node template is just a template used for testing.

Reviewed By: dlvhdr

Differential Revision: D17327549

fbshipit-source-id: 803ac26df1b866e721edee97999d199b0935098b
2019-09-12 01:24:16 -07:00
Ariel Mashraki
7dfe3c174c sql/schema: more precise blob definition
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/29

Reviewed By: alexsn

Differential Revision: D17284406

fbshipit-source-id: 84c2ffb50b8f016ad361f1420c5352c7969cbc77
2019-09-10 12:40:37 -07:00
Ariel Mashraki
d820361a3a entc/gen: add inc/dec capability for numeric fields
Reviewed By: alexsn

Differential Revision: D17259987

fbshipit-source-id: ad5ba1ba7383418463bc9137d82f16eadef809e7
2019-09-10 06:00:34 -07:00
Ariel Mashraki
61b8ccea4a entc/load: enable adding additional fields to the generated entities
Summary: In some cases (like xwf auth service), you want to add additional fields to the generated model.

Reviewed By: alexsn

Differential Revision: D17223674

fbshipit-source-id: fb4be71b388c6bd107e6bac242133c237fe25599
2019-09-08 08:05:13 -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
Alex Snast
b71ee6820b ent/schema: remove string field charset / collation settings
Summary: don't expose starage specific features in ent schema

Reviewed By: a8m

Differential Revision: D17111724

fbshipit-source-id: fca9e624b272c0db3fed14c511fa6cb07816a100
2019-08-29 07:38:39 -07:00
Ariel Mashraki
52b268c05c ent/doc: crud api
Reviewed By: alexsn

Differential Revision: D17094376

fbshipit-source-id: 9b1da24b99bb3ff15382b3a17516904decbca322
2019-08-28 11:23: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
Ariel Mashraki
a964901521 ent/doc: ui changes for homepage
Reviewed By: alexsn

Differential Revision: D17074003

fbshipit-source-id: 7a0088f8eab37dab570eaace5fa836d70bb708ed
2019-08-28 05:30:24 -07:00
Alex Snast
4c1f28d58f ent/schema: allow setting collation for string fields
Reviewed By: a8m

Differential Revision: D17090481

fbshipit-source-id: a08768c9bac4318a91bc6a067c85d6eb022c3024
2019-08-28 04:52:32 -07:00
Ariel Mashraki
9207ab5bb1 entc/integration: fix broken test
Reviewed By: alexsn

Differential Revision: D17090600

fbshipit-source-id: 53edd9bfdc794a2fc1669fb0ccde36ee6bdad0c1
2019-08-28 02:15:18 -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
772b8a33f8 ent/field: add update_default option time field
Reviewed By: alexsn

Differential Revision: D17070907

fbshipit-source-id: 63c9ce75c58e524044c38f9461cb04e8e45c8017
2019-08-27 06:54:49 -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
3e7270e835 ent/schema: change ent interafces for descriptor only
Summary: wip

Reviewed By: alexsn

Differential Revision: D17052576

fbshipit-source-id: 165faca2ff02c22bb76f164d81d406ce46ab04c4
2019-08-27 03:58:25 -07:00
Ariel Mashraki
52292557f6 entc/indexes: inverse only restriction applies only on O2O relation
Reviewed By: alexsn

Differential Revision: D17004823

fbshipit-source-id: 08b62960b447a157419dbeefd80ca1fcd29efd76
2019-08-25 06:41:14 -07:00
Alex Snast
e6a1333b9d ent/schema: allow multi from edges on ent index
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/24

Reviewed By: a8m

Differential Revision: D16961315

fbshipit-source-id: cd7cd0fe2555dc1acc2ad7301d92b5b4cd042a39
2019-08-22 07:00:29 -07:00
Ariel Mashraki
3bd8c27cb9 entc/predicate: add containsfold sql dialects (#23)
Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/23

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

Reviewed By: alexsn

Differential Revision: D16961334

fbshipit-source-id: 759737dd716efca01b1089715907e92fa2b4c8c7
2019-08-22 06:23:31 -07:00
Ariel Mashraki
f519a5465e schema/field: add builder per numeric type
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/21

Reviewed By: alexsn

Differential Revision: D16936906

fbshipit-source-id: 06f5721ed0088107cf42382731f8b7282f22eef7
2019-08-21 08:00:01 -07:00
Ariel Mashraki
eb3f140e67 entc/integration: add test for bool predicates
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/19

Reviewed By: alexsn

Differential Revision: D16917224

fbshipit-source-id: 6f4c388f504c61e5e25e3ca4a4b29a3d2736ab62
2019-08-20 08:13:40 -07:00
Ariel Mashraki
24d03df613 ent/ci: install goimports before running tests
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/16

Reviewed By: alexsn

Differential Revision: D16914392

fbshipit-source-id: 7f0fc01fb760b0712341810796d6539f549a9b5f
2019-08-20 06:07:08 -07:00
Alex Snast
85b29631a8 entc/schema: adding support for immutable fields (#1340)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1340

Immutable fields are ent fields which cannot be updated

Reviewed By: a8m

Differential Revision: D16899625

fbshipit-source-id: ca482c66570e84ca9a1e0a03f729847561f2816b
2019-08-20 02:17:13 -07:00
Ariel Mashraki
e0e754717e ent: change ent package name (#1338)
Summary:
Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1338

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

Reviewed By: alexsn

Differential Revision: D16890825

fbshipit-source-id: 656baaa73f5debab08c849b6b9639caeec2a8ef1
2019-08-19 09:32:14 -07:00
Alex Snast
a209a8395e schema/field: Allow .Unique() definition on int / float fields
Reviewed By: a8m

Differential Revision: D16891088

fbshipit-source-id: b3d8375685b6d1957f678c2f9eb40e172891b255
2019-08-19 06:35:26 -07:00
Ariel Mashraki
7438104b5d entc/sql/decode: use null types for fields scanning
Reviewed By: alexsn

Differential Revision: D16890638

fbshipit-source-id: bfe3699831875a559d322a500ffc20a976f30a44
2019-08-19 05:02:37 -07:00
Ariel Mashraki
079ba191e3 ent/field: add default value for time
Reviewed By: alexsn

Differential Revision: D16890453

fbshipit-source-id: 362ae9e9666c523bdcce16503441565b6279ff08
2019-08-19 04:21:25 -07:00
Ariel Mashraki
c16d3c8e25 ent/schema: explicitly defines non-null fields in schema
Reviewed By: alexsn

Differential Revision: D16791620

fbshipit-source-id: bad3ac7b2349d2f483c804eb3623c6dfa8b06313
2019-08-15 03:37:17 -07:00