From 100d300094cb5f3306d29f760940ee873d200e90 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Mon, 25 May 2020 20:05:17 +0300 Subject: [PATCH] schema/field: add GoType option for string fields (#500) --- entc/gen/internal/bindata.go | 8 +- entc/gen/template/dialect/sql/predicate.tmpl | 5 +- entc/gen/template/where.tmpl | 25 ++- entc/gen/type.go | 49 +++++- entc/integration/customid/ent/blob/where.go | 6 +- entc/integration/customid/ent/car/where.go | 6 +- entc/integration/ent/card/where.go | 24 ++- entc/integration/ent/comment/where.go | 18 +- entc/integration/ent/fieldtype/where.go | 156 ++++++++++++------ entc/integration/ent/file/where.go | 24 ++- entc/integration/ent/filetype/where.go | 6 +- entc/integration/ent/group/where.go | 24 ++- entc/integration/ent/groupinfo/where.go | 12 +- entc/integration/ent/node/where.go | 6 +- entc/integration/ent/pet/where.go | 6 +- entc/integration/ent/user/where.go | 54 ++++-- entc/integration/gremlin/ent/card/where.go | 8 + entc/integration/gremlin/ent/comment/where.go | 6 + .../gremlin/ent/fieldtype/where.go | 52 ++++++ entc/integration/gremlin/ent/file/where.go | 8 + .../integration/gremlin/ent/filetype/where.go | 2 + entc/integration/gremlin/ent/group/where.go | 8 + .../gremlin/ent/groupinfo/where.go | 4 + entc/integration/gremlin/ent/node/where.go | 2 + entc/integration/gremlin/ent/pet/where.go | 2 + entc/integration/gremlin/ent/user/where.go | 18 ++ entc/integration/hooks/ent/card/where.go | 18 +- entc/integration/hooks/ent/user/where.go | 12 +- entc/integration/idtype/ent/user/where.go | 6 +- entc/integration/migrate/entv1/user/where.go | 42 +++-- entc/integration/migrate/entv2/user/where.go | 54 ++++-- entc/integration/privacy/ent/galaxy/where.go | 12 +- entc/integration/privacy/ent/planet/where.go | 12 +- entc/integration/template/ent/group/where.go | 6 +- entc/integration/template/ent/pet/where.go | 12 +- entc/integration/template/ent/user/where.go | 6 +- examples/edgeindex/ent/city/where.go | 6 +- examples/edgeindex/ent/street/where.go | 6 +- examples/m2m2types/ent/group/where.go | 6 +- examples/m2m2types/ent/user/where.go | 12 +- examples/m2mbidi/ent/user/where.go | 12 +- examples/m2mrecur/ent/user/where.go | 12 +- examples/o2m2types/ent/pet/where.go | 6 +- examples/o2m2types/ent/user/where.go | 12 +- examples/o2mrecur/ent/node/where.go | 6 +- examples/o2o2types/ent/card/where.go | 12 +- examples/o2o2types/ent/user/where.go | 12 +- examples/o2obidi/ent/user/where.go | 12 +- examples/o2orecur/ent/node/where.go | 6 +- examples/start/ent/car/where.go | 12 +- examples/start/ent/group/where.go | 6 +- examples/start/ent/user/where.go | 12 +- examples/traversal/ent/group/where.go | 6 +- examples/traversal/ent/pet/where.go | 6 +- examples/traversal/ent/user/where.go | 12 +- schema/field/field.go | 119 ++++++++++--- schema/field/field_test.go | 45 +++++ schema/field/type.go | 61 ++++++- 58 files changed, 845 insertions(+), 273 deletions(-) diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 0beaf3b92..faaba0981 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -766,7 +766,7 @@ func templateDialectSqlOpenTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlPredicateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x56\x5d\x6b\x23\x37\x14\x7d\x9e\xf9\x15\x97\x10\xa8\xbc\x38\x72\x9c\xb7\x16\x52\x08\xae\x4d\x4d\x77\x9d\xb4\x0e\xdd\x87\x10\x8a\x32\xba\xe3\x11\xab\x48\x8a\x24\x8f\x31\xc3\xfc\xf7\x22\x79\x3c\x1e\x3b\xd9\x4d\xea\xb4\xd0\x87\x7d\x1b\xeb\x7e\x9f\x73\xae\xe4\xaa\x1a\x7c\x48\x47\xda\xac\xad\x58\x14\x1e\x2e\xce\x87\x3f\x9e\x19\x8b\x0e\x95\x87\x09\xcb\xf0\x41\xeb\x2f\x30\x55\x19\x85\x2b\x29\x21\x3a\x39\x08\x76\x5b\x22\xa7\xe9\x6d\x21\x1c\x38\xbd\xb4\x19\x42\xa6\x39\x82\x70\x20\x45\x86\xca\x21\x87\xa5\xe2\x68\xc1\x17\x08\x57\x86\x65\x05\xc2\x05\x3d\xdf\x5a\x21\xd7\x4b\xc5\x53\xa1\xa2\xfd\xe3\x74\x34\x9e\xcd\xc7\x90\x0b\x89\xd0\x9c\x59\xad\x3d\x70\x61\x31\xf3\xda\xae\x41\xe7\xe0\x3b\xc5\xbc\x45\xa4\xe9\x87\x41\x5d\xa7\x69\x55\x01\xc7\x5c\x28\x84\x13\x2e\x98\xc4\xcc\x0f\xdc\x93\x1c\x18\x8b\x5c\x64\xcc\xe3\x40\xf0\x13\x38\xab\xeb\x34\xc9\x97\x2a\x23\x0e\x3e\xb8\x27\x49\xe7\x28\x63\xea\x1e\x54\x69\x92\x38\xfa\xb9\x40\x8b\x24\x58\xc6\xbf\x13\x47\x47\xa4\xaa\xe0\x94\x4e\x7f\xa1\x23\xad\x9c\x67\xca\x43\x5d\xf7\xfa\x20\x78\xaf\x97\x26\x75\x5a\x55\x67\x80\x8a\xc3\x1b\x1b\x18\x68\xe3\x9a\x26\x42\xe4\xa9\x36\xf0\xd3\x25\x9c\xd2\x79\xa6\x0d\xd2\x6b\xd3\x31\x31\xbb\xe8\xda\xae\xec\xa2\x63\x74\x5e\x5b\xb6\xc0\xae\xc3\xbc\x39\x7a\x65\xc2\x10\x2e\xf2\x50\x99\xfe\xc9\xac\x60\x5c\x64\xa1\xf9\x24\x49\x06\x83\x60\x50\xda\x03\xb3\x8b\xe5\x23\x2a\xef\x60\x85\x16\xc1\x58\x5d\x0a\x8e\xbc\x0f\xcc\x98\x30\x6c\xe0\x65\x72\xf5\x71\x3e\x86\xac\x01\xc5\xf5\x9b\x0c\x4e\xa8\x0c\x61\x85\x90\x31\xf5\x83\x0f\x01\x72\x0d\x27\xd3\x19\x90\xde\x09\x85\xa8\x93\x95\x90\x12\x1e\xd9\x17\xdc\x30\xd9\xc2\x03\x39\x93\x6e\x4d\x43\x22\x91\x83\x44\x15\xa1\x0f\x30\xd4\x75\x0f\x2e\x2f\xe1\x3c\x0e\xb0\x4f\xd2\x84\x49\x87\x24\x70\x91\x24\x89\x45\xbf\xb4\x2a\x7c\xc6\x81\xca\x00\x4f\x28\x44\xee\xee\x85\xf2\x68\x73\x96\x61\x55\xf7\x0f\x73\xc7\xe0\x5c\x5b\x10\x21\xc0\x32\xb5\x40\x28\x9b\x5a\xe5\x9d\xb8\x87\x4b\xd8\x79\xdf\x89\xfb\x6d\x81\x0e\xf7\xfb\x4d\x55\x15\x64\x4c\xca\x96\x26\x7a\x6d\x46\x61\x2b\x02\xdd\x75\xfd\x0d\x55\x55\xd5\x0b\xdc\x94\x94\x86\x8c\x28\x1d\x42\x5d\x0b\x1e\xbe\x63\xd5\x23\x14\x98\x0b\x94\xbc\x2b\xc0\xbc\x2b\xa1\x49\xb0\x1e\xb9\x22\xf9\xc1\x28\xe5\xb1\xdd\x1d\xae\xc8\xd7\x3a\xfc\xbe\x3f\xff\xf1\xfe\xbc\x57\xde\xfb\x8a\xd8\x48\x3b\xa0\x13\xa0\x9b\x09\xd9\x20\xd7\x87\xf2\x45\xd5\x37\xa2\x8f\xf5\xdf\xa3\x78\xe4\x0b\x1c\x14\x6c\x4f\x52\x7b\xbc\x8f\xf9\xeb\xa4\x3b\x8f\x51\x68\xee\x49\x2e\x2c\x33\x05\x9d\xe1\x6a\xee\xd1\x90\x80\x55\x7b\x38\xb1\xfa\x91\xdc\xb2\x07\x89\x71\x93\x9f\xef\xf7\x9e\xf7\xad\x8e\x28\x21\x8d\x11\x1d\xbf\xb7\x04\x87\xa6\x49\xfb\x6b\x93\xe7\x0f\x94\xf4\x76\x6d\xb0\x4d\x81\x74\xea\xa6\xaa\x44\xeb\xba\x67\xcf\xca\x45\xea\xb7\xb2\x46\xfa\xe9\xe2\xd3\x06\x8e\xcd\x71\x38\xba\xf9\xad\xe3\x4f\x29\x6d\x23\xe2\x9d\x74\xe0\x3c\xd2\x72\xf9\xa8\x3a\x01\x3b\x6f\xc5\xb7\xce\x71\x9c\x20\xba\x76\x86\x5f\x99\x9b\xa1\x58\x14\x0f\xda\x3a\xe2\xfa\x10\x20\x3f\x9e\xed\x95\xf0\xc5\xff\x94\xf1\xb0\x05\x08\xa7\x1b\x1e\x22\x21\x6b\xd3\xb0\xb2\x91\x7a\xe0\x6d\xc3\xda\x21\x55\xbb\x57\x20\x5a\xda\xb5\xf8\xae\x98\xcf\xc2\x17\x5b\xd5\xf4\xe1\xeb\xb4\xc6\x67\xfe\xaf\x3e\x98\xdd\x4b\x1f\xc4\xe3\x9a\x9b\xd1\x10\xd7\xdb\x5e\x7f\xf5\x3f\x57\x1f\x53\x6f\xf8\x87\x39\x8c\xb2\xa2\x23\xa9\x15\x92\x1e\x9d\xa3\xbf\x21\x4a\xc8\x50\xf7\xe5\xe6\x62\xee\xa6\x43\x43\xdc\x30\x78\xee\x5d\xc9\x43\x7a\x43\x8e\xb8\x19\xb5\x7d\x77\xb3\xe2\x9b\xcd\x8a\x1c\x04\xfc\xbc\x7b\x76\x86\xf4\xda\x92\x16\xdf\x7f\x75\x16\xa5\xfd\xab\xc3\x18\xe2\xe8\x4c\xfb\xe7\xe9\xff\x0e\x00\x00\xff\xff\x4a\xed\x3f\xf7\xfd\x0c\x00\x00") +var _templateDialectSqlPredicateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x56\xdf\x4f\xeb\x36\x14\x7e\x4e\xfe\x8a\x23\x84\x34\x17\x15\x17\x78\xdb\x24\x26\xa1\xae\xd5\xaa\xdd\x5b\xd8\x8a\x76\x1f\x10\x9a\x4c\x7c\x92\x58\xd7\xd8\xc6\x76\x5b\x55\x51\xfe\xf7\xc9\x4e\x9a\xa6\xc0\x80\x0b\x9b\xb4\x87\xfb\xd6\xfa\xfc\xfe\xbe\xef\x38\xae\xaa\xd1\x51\x3a\xd6\x66\x63\x45\x51\x7a\x38\x3b\x39\xfd\xf1\xd8\x58\x74\xa8\x3c\x4c\x59\x86\x77\x5a\x7f\x85\x99\xca\x28\x5c\x48\x09\xd1\xc9\x41\xb0\xdb\x15\x72\x9a\x5e\x97\xc2\x81\xd3\x4b\x9b\x21\x64\x9a\x23\x08\x07\x52\x64\xa8\x1c\x72\x58\x2a\x8e\x16\x7c\x89\x70\x61\x58\x56\x22\x9c\xd1\x93\xad\x15\x72\xbd\x54\x3c\x15\x2a\xda\x3f\xcd\xc6\x93\xf9\x62\x02\xb9\x90\x08\xed\x99\xd5\xda\x03\x17\x16\x33\xaf\xed\x06\x74\x0e\xbe\x57\xcc\x5b\x44\x9a\x1e\x8d\xea\x3a\x4d\xab\x0a\x38\xe6\x42\x21\x1c\x70\xc1\x24\x66\x7e\xe4\x1e\xe4\xc8\x58\xe4\x22\x63\x1e\x47\x82\x1f\xc0\x71\x5d\xa7\x49\xbe\x54\x19\x71\x70\xe4\x1e\x24\x5d\xa0\x8c\xa9\x07\x50\xa5\x49\xe2\xe8\x97\x12\x2d\x92\x60\x99\xfc\x4e\x1c\x1d\x93\xaa\x82\x43\x3a\xfb\x85\x8e\xb5\x72\x9e\x29\x0f\x75\x3d\x18\x82\xe0\x83\x41\x9a\xd4\x69\x55\x1d\x03\x2a\x0e\x6f\x6c\x60\xa4\x8d\x6b\x9b\x08\x91\x87\xda\xc0\x4f\xe7\x70\x48\x17\x99\x36\x48\x2f\x4d\xcf\xc4\x6c\xd1\xb7\x5d\xd8\xa2\x67\x74\x5e\x5b\x56\x60\xdf\x61\xd1\x1e\xbd\x32\x61\x08\x17\x79\xa8\x4c\xff\x64\x56\x30\x2e\xb2\xd0\x7c\x92\x24\xa3\x51\x30\x28\xed\x81\xd9\x62\x79\x8f\xca\x3b\x58\xa3\x45\x30\x56\xaf\x04\x47\x3e\x04\x66\x4c\x18\x36\xf0\x32\xbd\xf8\xb4\x98\x40\xd6\x82\xe2\x86\x6d\x06\x27\x54\x86\xb0\x46\xc8\x98\xfa\xc1\x87\x00\xb9\x81\x83\xd9\x1c\xc8\xe0\x80\x42\xd4\xc9\x5a\x48\x09\xf7\xec\x2b\x36\x4c\x76\xf0\x40\xce\xa4\xdb\xd0\x90\x48\xe4\x20\x51\x45\xe8\x03\x0c\x75\x3d\x80\xf3\x73\x38\x89\x03\xec\x93\x34\x65\xd2\x21\x09\x5c\x24\x49\x62\xd1\x2f\xad\x0a\x3f\xe3\x40\xab\x00\x4f\x28\x44\x6e\x6e\x85\xf2\x68\x73\x96\x61\x55\x0f\x1f\xe7\x8e\xc1\xb9\xb6\x20\x42\x80\x65\xaa\x40\x58\xb5\xb5\x56\x37\xe2\x16\xce\x61\xe7\x7d\x23\x6e\xb7\x05\x7a\xdc\xef\x37\x55\x55\x90\x31\x29\x3b\x9a\xe8\xa5\x19\x87\xad\x08\x74\xd7\xf5\x0b\xaa\xaa\xaa\x67\xb8\x59\x51\x1a\x32\xa2\x74\x08\x75\x2d\x78\xf8\x1d\xab\xbe\x43\x81\xb9\x40\xc9\xfb\x02\xcc\xfb\x12\x9a\x06\xeb\x1b\x24\xf8\xcd\xfb\x93\x3f\x9d\xb3\x07\xfe\x7b\x66\x78\xbc\x48\x2f\xce\xf1\x7d\xcb\xfe\xbb\x2d\xfb\xe8\x12\xec\x4b\xa3\x59\x80\x80\x4e\x80\x6e\x2e\x64\x8b\x5c\x5f\x32\xcf\x2e\x49\xbb\x23\xb1\x91\x8f\x2c\x08\xf2\x02\x47\x25\xdb\xd3\xd6\x9e\x00\x26\xfc\x75\xf6\x9d\xc7\xa8\x38\xf7\x20\x0b\xcb\x4c\x49\xe7\xb8\x5e\x78\x34\x24\x80\xd6\x1d\x4e\xad\xbe\x27\xd7\xec\x4e\x62\x33\xdd\x93\xeb\x60\xcf\xfb\x5a\x47\xb8\x90\xc6\x88\x9e\xdf\x5b\x82\x43\xd3\xa4\xfb\xd7\xe4\xf9\x03\x25\xbd\xde\x18\xec\x52\x20\x9d\xb9\x99\x5a\xa1\x75\xfd\xb3\x27\xe5\xa2\x06\xb6\xfa\x46\xfa\xf9\xec\x73\x03\x47\x73\x1c\x8e\xae\x7e\xeb\xf9\x53\x4a\xbb\x88\x78\x85\x3d\x72\x1e\x6b\xb9\xbc\x57\xbd\x80\x9d\xb7\xe2\x5b\xe7\x38\x4e\x50\x5f\x37\xc3\xaf\xcc\xcd\x51\x14\xe5\x9d\xb6\x8e\xb8\x21\x04\xc8\xdf\xcf\xf6\x5a\xf8\xf2\x7f\xca\x78\x58\x07\x84\xc3\x86\x87\x48\xc8\xc6\xb4\xac\x34\x52\x0f\xbc\x35\xac\x3d\xa6\x6a\xf7\xd1\x88\x96\x6e\x2d\xbe\x2b\xe6\x8b\xf0\xe5\x56\x35\x43\xf8\x67\x5a\xe3\xab\xe0\xaf\x21\x98\xdd\xc3\x20\x88\xc7\xb5\x57\xa4\x21\x6e\xb0\xbd\x07\xeb\x6f\x57\x1f\x53\x6f\x78\x90\x9e\x46\x59\xd1\xb1\xd4\x0a\xc9\x80\x2e\xd0\x5f\x11\x25\x64\xa8\xfb\x7c\x73\x31\x77\xdb\xa1\x21\xee\x34\x78\xee\xdd\xcd\xa7\xf4\x8a\xbc\xe3\x66\xd4\xf6\xc3\xcd\x8a\x17\x9b\x15\x39\x08\xf8\x79\xf7\xfd\x39\xa5\x97\x96\x74\xf8\xfe\xab\xb3\x28\xed\x5f\x1d\xc6\x10\x47\xe7\xda\x3f\x4d\xff\x77\x00\x00\x00\xff\xff\xef\xa4\xbd\xbb\x2c\x0d\x00\x00") func templateDialectSqlPredicateTmplBytes() ([]byte, error) { return bindataRead( @@ -781,7 +781,7 @@ func templateDialectSqlPredicateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 3325, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 3372, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -1106,7 +1106,7 @@ func templateTxTmpl() (*asset, error) { return a, nil } -var _templateWhereTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x57\x4d\x6f\xe3\x36\x13\x3e\x4b\xbf\x62\x20\x28\x78\xed\x60\x43\xed\xbb\xb7\x16\xc8\xc1\xd8\x64\xb1\x2e\x0a\xbb\x6d\x16\xed\x21\x08\x0a\x46\x1c\x59\x44\x64\x52\x4b\xd2\xce\x06\x82\xff\x7b\x31\xa4\x2c\x39\xfe\x48\x9c\xae\x51\xec\xcd\x26\x87\xf3\xf1\x3c\xcf\x0c\xc5\xa6\xc9\xce\xe3\x8f\xba\x7e\x32\x72\x56\x3a\xf8\xf0\xfe\xff\x3f\x5d\xd4\x06\x2d\x2a\x07\x9f\x78\x8e\xf7\x5a\x3f\xc0\x58\xe5\x0c\x46\x55\x05\xde\xc8\x02\xed\x9b\x25\x0a\x16\x7f\x29\xa5\x05\xab\x17\x26\x47\xc8\xb5\x40\x90\x16\x2a\x99\xa3\xb2\x28\x60\xa1\x04\x1a\x70\x25\xc2\xa8\xe6\x79\x89\xf0\x81\xbd\x5f\xef\x42\xa1\x17\x4a\xc4\x52\xf9\xfd\x5f\xc7\x1f\xaf\x27\x37\xd7\x50\xc8\x0a\xa1\x5d\x33\x5a\x3b\x10\xd2\x60\xee\xb4\x79\x02\x5d\x80\xdb\x08\xe6\x0c\x22\x8b\xcf\xb3\xd5\x2a\x8e\x9b\x06\x04\x16\x52\x21\x24\x8f\x25\x1a\x4c\x20\xac\x5e\xc0\xa3\x74\x25\xe0\x37\x87\x4a\x40\x0a\xc9\x6f\x3c\x7f\xe0\x33\x4c\x20\x65\xed\x4f\xb8\x58\xad\xe2\xa8\x69\xc0\xe1\xbc\xae\xb8\x43\x48\x4a\xe4\x02\x4d\x02\x8c\xbc\x34\x0d\xd0\xd9\x36\x4a\x6f\x24\xe7\xb5\x36\x2e\x81\xd4\x6f\x65\x19\x8c\xaf\x28\x79\x87\xc6\xc2\x12\x8d\x93\x39\x5a\xb8\xe7\x84\x82\xf6\xe5\x48\x03\x52\xa0\x72\xb2\x90\x68\x58\x5c\x2c\x54\x0e\xe3\xab\x81\x14\xd0\x34\x90\xb2\xf1\x15\xfb\xf2\x54\x23\xac\x56\x43\xa8\x0d\x0a\x99\x73\x87\xcc\x6f\x4d\xf8\x9c\xd6\xa1\x89\x23\x83\x6e\x61\xd4\x01\x83\x41\x1c\x45\x54\x73\xea\xe6\x75\x05\x3f\x5f\x42\x6d\xa4\x72\x05\x24\x42\xf2\x0a\x73\x97\x9d\xd9\xac\x3b\x99\x49\x41\x28\xdc\x38\x6d\x08\x05\x02\xc1\x1f\xfe\xd6\x95\x18\xdc\xa4\x01\xa0\x61\x1c\x00\x30\x5c\xcd\x10\xd2\xbf\xdf\x41\xaa\x6b\x8a\xa1\x6b\xeb\xb3\x87\x16\xc6\x94\x9b\x19\xad\x27\xe4\x7f\xb5\x6a\x1a\x90\x05\xd9\xb2\x3f\xb9\x91\x5c\xc8\x3c\x2c\x7a\x33\x6f\x65\x5b\xb3\x16\x65\xef\xc3\x83\xb3\x51\xc0\xf8\xea\xcc\x26\xde\x4b\x5b\x6a\x1c\x65\x19\x74\x96\xab\x15\xf0\xba\xae\x24\x5a\xaf\x1b\x5a\xef\x4d\x7b\xb0\x5a\x22\x02\x53\x58\x09\x16\x47\xfe\xf8\x86\x9f\xc1\x3a\x35\x82\x7b\x5f\xea\x8c\xb1\x2e\xd7\x37\xf0\xf6\x3a\x71\xd1\x1e\xb5\x8e\xcc\x2c\x09\xe9\x24\xd3\xda\xd7\x0f\x49\x4b\xd8\x26\x77\x9e\x20\xef\xe1\x68\xea\x33\x5d\xdb\x1d\xfa\xf7\x0b\x80\xb5\x9b\xb4\x47\x79\x85\x68\xc3\x38\xda\xee\x8d\x0d\x69\x14\x94\x42\xca\x3e\x11\xca\xb6\x65\x35\x3b\x87\x5f\x6e\xa6\x13\xc8\xb9\x52\xda\xc1\x3d\x8d\x8b\x79\xcd\x0d\x8d\x09\x2b\xd5\x0c\x92\xcb\x04\xb8\x12\x70\xad\x16\x73\x28\xb9\x05\x0e\x8e\x90\x0d\x9d\x2d\x02\x38\xc4\x9f\x27\x0f\x14\x61\xe7\xdb\xdf\xa7\x26\x0b\x20\xb7\x03\x6d\x20\x2d\xd8\xd8\xfa\x58\xfe\x17\xf9\x1b\xae\x05\xde\x6b\x2b\x2d\xd8\x8d\x33\x8b\xdc\xf9\x2c\xc3\xfe\x01\x51\xe1\xd7\x05\xaf\xa4\x7b\x82\xbc\xc4\xfc\x61\x57\x50\x4d\x03\x5f\x17\x9a\x10\x2b\x3a\xd2\x83\xc2\x60\xec\xfe\x67\xdb\xbe\xcf\x79\x05\x4e\x6f\x06\xb8\xfe\x9d\xc5\xd1\xae\x06\x97\xe1\xdf\x51\xba\x3a\x42\x58\xfb\x94\xe5\x6b\x4e\x88\xa8\xb5\x78\x8e\x57\x4f\xd1\x9e\xdd\x16\xcf\x8b\xea\xd9\x92\x0f\xe9\x27\x6a\x99\x6b\x25\xf4\x26\x31\x51\x2f\xd8\x6e\xfc\x14\xeb\x55\x5f\x65\x97\x18\x9b\xd6\xb6\xe7\x9d\x2c\x2f\x89\x52\x54\xc2\x86\xbf\x83\x9c\x57\xd5\x96\x7d\x5a\x0c\xd7\xde\x36\x26\xd2\xce\xd8\xf3\xe7\xb7\x47\xde\xf2\x98\x89\xb7\x7c\x75\xe0\x6d\x4b\xf3\xd9\xdc\xf3\x34\x91\x30\x82\x84\x49\x23\x64\x4c\x0d\xd4\xc5\x5e\xab\xbe\x0d\xec\xcd\x2f\xc1\x19\x39\x5f\x5f\x7a\x61\xad\xbf\x04\x9f\x25\xf4\x1d\xa3\xf5\x70\x27\xec\x9f\xb5\x6d\xd7\x7a\x9f\xb2\xda\x02\xeb\xd8\x19\xec\x42\x9f\x74\x6b\x2f\x36\x4c\x3b\x2b\xb6\x5c\x92\x24\x97\x04\xe9\x9c\x3f\xe0\xe0\xf6\x4e\x2a\x87\xa6\xe0\x39\x36\xab\x77\x50\xa1\xda\xb8\x17\x86\x24\xdd\xa8\xd0\x06\x24\x1d\x08\xca\x58\x86\x66\x8c\x96\xb7\xf2\x0e\x2e\xa1\xb7\xbe\x95\x77\xb4\xb1\xbe\x5d\xd7\x10\x7f\xf7\x7d\xd0\x37\xf0\x69\xaf\x06\x4f\xd6\x69\x6e\x87\x8d\x16\x3a\xd8\xdb\x41\xc6\xec\x5a\xcc\xd0\x1e\x68\x86\xe4\x33\xa7\x64\x70\x67\x5a\xbf\x20\xd3\xcf\xdc\x92\xcb\x97\xf4\x89\x9d\x2a\x50\xcc\x70\x9f\x3c\x4f\x7f\x9f\x53\x4e\x54\xca\xdb\x69\xa1\x1c\xb3\x92\x9f\x88\x95\x50\x62\x1f\xf2\xcc\xfe\x25\x5d\x99\x74\xa5\x9f\x16\xdb\x80\x02\x87\x99\x5c\xa2\x82\x5c\x2b\x21\x9d\xd4\xca\xc2\x40\xbb\x12\x4d\xef\xc8\x0e\xf7\xd1\x40\xdb\x16\x18\x63\xcf\xb1\xc6\x30\xfa\xda\x40\x3f\x22\x57\x8f\x01\xd3\xd3\x7d\x63\x65\x19\x8c\x94\x80\x99\xd1\x8b\x9a\x1e\x59\xd6\xd1\x9b\xa8\x87\xaf\xff\x42\x1a\x4d\xae\x40\xd7\x68\xb8\xd3\x06\xee\xd1\x3d\x22\x7a\x8e\xe6\xed\xbb\x63\xa4\xc4\x60\xe3\xdc\x0e\xb8\xc7\xc0\xfa\x86\xa7\xc8\x2b\x80\x71\x75\xdc\x53\x84\x6d\x3c\x45\xb2\x0c\xa6\xe6\x18\x28\xa6\x7f\xbc\x88\xc4\xd4\xfc\x40\x40\x68\xf3\x6f\x70\x98\x68\xf7\xac\x41\xe9\x42\xed\x4a\x6e\x7b\x33\xf4\x5e\x9f\x62\x28\x7e\xa2\xdd\xa0\x3e\x90\xf8\x7f\x53\xb1\xd2\xee\xcd\x25\xf7\x1d\xf1\x4f\x00\x00\x00\xff\xff\x47\x00\x3c\x5d\xbb\x10\x00\x00") +var _templateWhereTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x57\xdf\x6f\xdb\x36\x10\x7e\xb6\xfe\x8a\x83\xa0\x62\x72\xd1\x50\x5d\xdf\x36\x20\x0f\x59\x93\xae\x1e\x86\xa4\x5b\x8a\xed\xa1\x28\x06\x46\x3c\x59\x44\x64\x52\x25\x69\xa7\x81\xa0\xff\x7d\x38\x52\xbf\xec\x38\x89\xb3\x06\x43\xf3\xe4\x90\xc7\xfb\xf1\xdd\xf7\x1d\xc5\xa6\xc9\x5e\x46\x6f\x75\x7d\x6b\xe4\xb2\x74\xf0\xe6\xf5\x8f\x3f\x1d\xd5\x06\x2d\x2a\x07\xef\x78\x8e\x57\x5a\x5f\xc3\x42\xe5\x0c\x4e\xaa\x0a\xbc\x91\x05\xda\x37\x1b\x14\x2c\xfa\x58\x4a\x0b\x56\xaf\x4d\x8e\x90\x6b\x81\x20\x2d\x54\x32\x47\x65\x51\xc0\x5a\x09\x34\xe0\x4a\x84\x93\x9a\xe7\x25\xc2\x1b\xf6\xba\xdf\x85\x42\xaf\x95\x88\xa4\xf2\xfb\xbf\x2f\xde\x9e\x9d\x5f\x9e\x41\x21\x2b\x84\x6e\xcd\x68\xed\x40\x48\x83\xb9\xd3\xe6\x16\x74\x01\x6e\x12\xcc\x19\x44\x16\xbd\xcc\xda\x36\x8a\x9a\x06\x04\x16\x52\x21\xc4\x37\x25\x1a\x8c\x21\xac\x1e\xc1\x8d\x74\x25\xe0\x57\x87\x4a\x40\x02\xf1\x07\x9e\x5f\xf3\x25\xc6\x90\xb0\xee\x27\x1c\xb5\x6d\x34\x6b\x1a\x70\xb8\xaa\x2b\xee\x10\xe2\x12\xb9\x40\x13\x03\x23\x2f\x4d\x03\x74\xb6\x8b\x32\x1a\xc9\x55\xad\x8d\x8b\x21\xf1\x5b\x59\x06\x8b\x53\x4a\xde\xa1\xb1\xb0\x41\xe3\x64\x8e\x16\xae\x38\xa1\xa0\x7d\x39\xd2\x80\x14\xa8\x9c\x2c\x24\x1a\x16\x15\x6b\x95\xc3\xe2\x34\x95\x02\x9a\x06\x12\xb6\x38\x65\x1f\x6f\x6b\x84\xb6\x9d\x43\x6d\x50\xc8\x9c\x3b\x64\x7e\xeb\x9c\xaf\x68\x1d\x9a\x68\x66\xd0\xad\x8d\xba\xc7\x20\x8d\x66\x33\xaa\x39\x71\xab\xba\x82\x9f\x8f\xa1\x36\x52\xb9\x02\x62\x21\x79\x85\xb9\xcb\x5e\xd8\x6c\x38\x99\x49\x41\x28\x5c\x3a\x6d\x08\x05\x02\xc1\x1f\xfe\x3a\x94\x18\xdc\x24\x01\xa0\x79\x14\x00\x30\x5c\x2d\x11\x12\x5d\x93\x7f\x5d\x5b\x9f\x39\x74\x10\x26\xdc\x2c\x69\x3d\x26\xdf\x6d\xdb\x34\x20\x0b\xb2\x65\x7f\x71\x23\xb9\x90\x79\x58\xf4\x66\xde\xca\x76\x66\x1d\xc2\xde\x87\x07\x66\x92\xfc\xe2\xf4\x85\x8d\xbd\x97\xae\xcc\x68\x96\x65\x30\x58\xb6\x2d\xf0\xba\xae\x24\x5a\xcf\x19\x5a\x1f\x4d\x47\xa0\xba\x26\x84\x2e\x61\x25\x58\x34\xf3\xc7\x27\x7e\xd2\x3e\x35\x82\x7a\x5f\xea\x8c\xb1\x21\xd7\x27\xf4\xec\xf1\xa6\xcd\xf6\x30\xf5\xc4\x2c\xe3\x90\x4e\x7c\x51\xfb\xfa\x21\xee\x9a\x35\xed\x9b\x6f\x8e\xf7\x70\x70\xdb\x33\x5d\xdb\x3b\xad\xdf\xdf\x7c\xd6\x6d\xd2\x1e\xe5\x15\xa2\xcd\xa3\xd9\xae\x2e\x3a\x5a\x14\x14\x3e\x61\xef\x08\x61\xdb\x75\x34\x7b\x09\xbf\x5d\x5e\x9c\x43\xce\x95\xd2\x0e\xae\x68\x4c\xac\x6a\x6e\x68\x3c\x58\xa9\x96\x10\x1f\xc7\xc0\x95\x80\x33\xb5\x5e\x41\xc9\x2d\x70\x70\x84\x6a\x50\xb4\x08\xc0\x50\xef\x7c\xe3\x40\x11\x6e\x5e\xf6\xbe\xe8\x92\xdb\x0f\x14\x95\x7c\xa7\xda\x40\x52\xb0\x85\xf5\x01\xfd\x2f\x72\x3a\x1f\xb8\x15\x22\xf3\xab\x0a\x3d\x7d\x0d\xa4\x74\x2c\x29\xd8\x7b\x6e\x7f\xd5\xd4\xcb\x39\xa4\x49\xc1\x7e\xe1\x56\xe6\xbe\xb5\xf1\x26\xee\x8f\x1f\x11\x25\x28\xd1\x10\x73\xea\xac\x6d\x23\xe8\xfe\xa6\x32\xd8\xc4\xbd\xae\x46\x5a\x27\x05\xbb\x74\x66\x9d\x3b\x0f\x52\xd8\xbf\x87\xcf\xf8\x65\xcd\x2b\xe9\x6e\x21\x2f\x31\xbf\xbe\xcb\xe5\xa6\x81\x2f\x6b\x4d\xcd\x2a\x06\xbe\x05\x72\xc3\xc2\xfd\x60\xbb\x71\x93\xf3\x0a\x9c\x9e\x06\x38\xfb\x83\x45\xb3\xc7\xe8\x9f\x14\x07\x71\xbb\xc7\x65\x8a\x61\xcf\xa8\x8d\x2f\x38\xf8\xda\x42\x74\x8a\xd7\x2e\x6e\x04\x5b\x7e\xc7\xa2\x27\x60\xf0\xfc\xb8\xa0\x1e\x51\x94\xc7\x3e\x26\xbe\xf6\xfa\x39\x5c\x40\x45\x77\x76\x57\x3f\x0f\x0a\x68\x47\x41\x24\xa1\x59\x47\xaa\xae\xac\x83\xf5\x44\xa3\xc0\x0e\xd3\xb7\xe8\x57\x7d\xb1\x43\x52\xec\xa2\xb6\x23\xf7\xc8\xf2\x98\x68\x85\x4a\xd8\xf0\x6f\x9a\xf3\xaa\xda\xb1\x4f\x8a\x41\x29\x93\x81\xbc\x35\xf1\xfd\xd9\xdd\x69\xbf\x39\x64\xd8\x6f\x1e\x9d\xf5\xbb\xd2\xd8\x1a\xf9\xbe\x3d\x44\x9f\x20\x21\x62\x12\x19\xd3\xfc\x18\x62\xf7\x7a\xef\x02\x7b\xf3\x63\x70\x46\xae\xfa\xbb\x3e\xac\x8d\x77\xff\x56\x42\xdf\x70\xab\xdc\xaf\xc4\xfd\xd7\x8c\x2c\xfc\xbc\xf2\x3e\x65\xb5\x03\xd6\xa1\xd7\x8f\x0b\x52\x1b\xd6\x1e\xd4\x69\x2f\xd3\x6d\x97\x44\xc5\x0d\x41\xba\xe2\xd7\x98\x7e\xfa\x2c\x95\x43\x53\xf0\x1c\x9b\xf6\x15\x54\xa8\x26\x33\x61\x4e\x94\x9d\x15\xda\x80\xa4\x03\x81\x15\x9b\x30\x03\x66\x9b\x4f\xf2\x33\x1c\xc3\x68\xfd\x49\x7e\xa6\x8d\xee\xf2\x18\x49\x10\x8f\x1f\x1a\x58\x59\xec\x27\x6a\xba\x83\xc6\x7c\xdf\x3c\x79\x70\x9c\xec\xc4\xc9\xa7\x81\xfa\xb9\xf1\xad\xf7\xf0\x38\x35\x9e\xf7\x4a\xf6\x4c\x79\x9e\x5b\x79\xa2\xdd\xbd\x03\xe5\x9f\x57\x90\x04\x0d\xb1\x33\xb1\x44\x7b\x8f\x12\xe3\xf7\x9c\x92\xc1\x3b\x57\xd5\x03\x1a\x79\xcf\x2d\xb9\x7c\x48\x1c\x38\x50\x12\xc5\x12\xf7\x69\xe3\xf9\xbf\xa3\x28\x27\x2a\xe5\xe9\x6d\xa1\x1c\xb3\x92\x3f\x53\x57\x42\x89\x63\xc8\x17\xf6\x6f\xe9\xca\x78\x28\xfd\x79\xb1\x0d\x28\x70\x58\xca\x0d\x2a\xc8\xb5\x12\xd2\x49\xad\x2c\xa4\xda\x95\x68\x46\x47\x76\xbe\xaf\x0d\xb4\x6d\x81\x31\xb6\x8d\x35\x86\xb9\xdb\x05\xfa\x1e\x7b\x75\x13\x30\x7d\xbe\x6f\xdb\x2c\x83\x13\x25\x60\x69\xf4\xba\xa6\x87\xad\x75\xf4\x0e\x1d\xe1\x1b\xbf\x4e\x4f\xce\x4f\x41\xd7\x68\xb8\xd3\x06\xae\xd0\xdd\x20\xfa\x1e\xad\xba\xb7\xde\x89\x12\xe9\xe4\xdc\x1d\x70\x0f\x81\xf5\x09\xcf\xbf\x47\x00\xe3\xea\xb0\xe7\x1f\x9b\x3c\xff\xb2\x0c\x2e\xcc\x21\x50\x5c\xfc\xf9\x20\x12\x17\xe6\x3b\x02\x42\x9b\xff\x82\xc3\xb9\x76\x5b\x02\xa5\xfb\x6b\x28\xb9\xd3\x66\xd0\xde\x98\x62\x28\xfe\x5c\xbb\xb4\xbe\x27\xf1\xff\xa7\x62\xa5\xdd\x93\x4b\x1e\x15\xf1\x6f\x00\x00\x00\xff\xff\x1f\xb0\xc8\x6c\x2f\x12\x00\x00") func templateWhereTmplBytes() ([]byte, error) { return bindataRead( @@ -1121,7 +1121,7 @@ func templateWhereTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/where.tmpl", size: 4283, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/where.tmpl", size: 4655, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/dialect/sql/predicate.tmpl b/entc/gen/template/dialect/sql/predicate.tmpl index 437d7bfd8..5e92be849 100644 --- a/entc/gen/template/dialect/sql/predicate.tmpl +++ b/entc/gen/template/dialect/sql/predicate.tmpl @@ -33,8 +33,9 @@ in the LICENSE file in the root directory of this source tree. {{ define "dialect/sql/predicate/field" -}} {{- $f := $.Scope.Field -}} + {{- $arg := $.Scope.Arg -}} func(s *sql.Selector) { - s.Where(sql.EQ(s.C({{ $f.Constant }}), v)) + s.Where(sql.EQ(s.C({{ $f.Constant }}), {{ $arg }})) } {{- end }} @@ -52,7 +53,7 @@ in the LICENSE file in the root directory of this source tree. return } {{- end }} - s.Where(sql.{{ call $storage.OpCode $op }}(s.C({{ $f.Constant }}){{ if not $op.Niladic }}, v{{ if $op.Variadic }}...{{ end }}{{ end }})) + s.Where(sql.{{ call $storage.OpCode $op }}(s.C({{ $f.Constant }}){{ if not $op.Niladic }}, {{ $arg }}{{ if $op.Variadic }}...{{ end }}{{ end }})) } {{- end }} diff --git a/entc/gen/template/where.tmpl b/entc/gen/template/where.tmpl index ed4c36869..79370ff41 100644 --- a/entc/gen/template/where.tmpl +++ b/entc/gen/template/where.tmpl @@ -20,7 +20,7 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { ) } -{{ range $_, $op := ops $.ID }} +{{ range $op := ops $.ID }} {{ $arg := "id" }}{{ if $op.Variadic }}{{ $arg = "ids" }}{{ end }} {{ $func := printf "ID%s" $op.Name }} // {{ $func }} applies the {{ $op.Name }} predicate on the ID field. @@ -34,14 +34,21 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { } {{ end }} -{{ range $_, $f := $.Fields }} +{{ range $f := $.Fields }} {{/* JSON cannot be compared using "=" and Enum has a type defined with the field name */}} - {{- if not (or $f.IsJSON $f.IsEnum) }} + {{ $hasP := not (or $f.IsJSON $f.IsEnum) }} + {{ $comparable := or (not $f.HasGoType) ($f.BasicType "v") }} + {{- if and $hasP $comparable }} + {{ $arg := "v" }} {{ $func := $f.StructField }} // {{ $func }} applies equality check predicate on the {{ quote $f.Name }} field. It's identical to {{ $func }}EQ. - func {{ $func }}(v {{ $f.Type }}) predicate.{{ $.Name }} { + func {{ $func }}({{ $arg }} {{ $f.Type }}) predicate.{{ $.Name }} { + {{- if $f.HasGoType }} + vc := {{ $f.BasicType "v" }} + {{ $arg = "vc" }} + {{- end }} return predicate.{{ $.Name }}( - {{- with extend $ "Field" $f -}} + {{- with extend $ "Arg" $arg "Field" $f -}} {{ $tmpl := printf "dialect/%s/predicate/field" $.Storage }} {{- xtemplate $tmpl . }} {{- end -}} @@ -50,12 +57,12 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { {{- end }} {{ end }} -{{ range $_, $f := $.Fields }} +{{ range $f := $.Fields }} {{ $ops := ops $f }} {{ with $.Storage.Ops }} {{ $ops = appends $ops (call $.Storage.Ops $f) }} {{ end }} - {{ range $_, $op := $ops }} + {{ range $op := $ops }} {{ $arg := "v" }}{{ if $op.Variadic }}{{ $arg = "vs" }}{{ end }} {{ $func := print $f.StructField $op.Name }} {{ $type := $f.Type.String }}{{ if $f.IsEnum }}{{ $type = trimPackage $type $.Package }}{{ end }} @@ -66,6 +73,10 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { for i := range v { v[i] = {{ $arg }}[i] } + {{ $arg = "v" }} + {{- else if and (not $op.Niladic) $f.HasGoType }} + vc := {{ $f.BasicType "v" }} + {{ $arg = "vc" }} {{- end }} return predicate.{{ $.Name }}( {{- with extend $ "Arg" $arg "Field" $f "Op" $op "Storage" $.Storage -}} diff --git a/entc/gen/type.go b/entc/gen/type.go index 2db7099c8..b5c7db924 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -5,6 +5,7 @@ package gen import ( + "database/sql" "fmt" "go/token" "go/types" @@ -698,7 +699,7 @@ func (f Field) NullTypeField(rec string) string { case field.TypeEnum: return fmt.Sprintf("%s(%s.String)", f.Type, rec) case field.TypeString, field.TypeBool, field.TypeInt64, field.TypeFloat64: - return fmt.Sprintf("%s.%s", rec, strings.Title(f.Type.String())) + return fmt.Sprintf("%s.%s", rec, strings.Title(f.Type.Type.String())) case field.TypeTime: return fmt.Sprintf("%s.Time", rec) case field.TypeFloat32: @@ -766,7 +767,7 @@ func (f Field) PK() *schema.Column { } // StorageKey returns the storage name of the field. -// SQL columns or Gremlin property. +// SQL column or Gremlin property. func (f Field) StorageKey() string { if f.def != nil && f.def.StorageKey != "" { return f.def.StorageKey @@ -774,6 +775,50 @@ func (f Field) StorageKey() string { return snake(f.Name) } +// HasGoType indicate if a basic field (like string or bool) +// has a custom GoType. +func (f Field) HasGoType() bool { + return f.Type != nil && f.Type.RType != nil +} + +var ( + nullInt64Type = reflect.TypeOf(sql.NullInt64{}) + nullStringType = reflect.TypeOf(sql.NullString{}) +) + +// BasicType returns a Go expression for the given identifier +// to convert it to a basic type. For example: +// +// v (http.Dir) => string(v) +// v (fmt.Stringer) => v.String() +// v (database/sql.NullString) => v.String +// +func (f Field) BasicType(ident string) (expr string) { + if !f.HasGoType() { + return ident + } + t, rt := f.Type, f.Type.RType + switch t.Type { + case field.TypeInt64: + switch { + case rt.Kind == reflect.Int64: + expr = fmt.Sprintf("int64(%s)", ident) + case rt.TypeEqual(nullInt64Type): + expr = fmt.Sprintf("%s.Int64", ident) + } + case field.TypeString: + switch { + case rt.Kind == reflect.String: + expr = fmt.Sprintf("string(%s)", ident) + case t.Stringer(): + expr = fmt.Sprintf("%s.String()", ident) + case rt.TypeEqual(nullStringType): + expr = fmt.Sprintf("%s.String", ident) + } + } + return +} + // Label returns the Gremlin label name of the edge. // If the edge is inverse func (e Edge) Label() string { diff --git a/entc/integration/customid/ent/blob/where.go b/entc/integration/customid/ent/blob/where.go index 764686199..dabb424af 100644 --- a/entc/integration/customid/ent/blob/where.go +++ b/entc/integration/customid/ent/blob/where.go @@ -123,10 +123,11 @@ func UUIDIn(vs ...uuid.UUID) predicate.Blob { for i := range v { v[i] = vs[i] } + return predicate.Blob(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -140,10 +141,11 @@ func UUIDNotIn(vs ...uuid.UUID) predicate.Blob { for i := range v { v[i] = vs[i] } + return predicate.Blob(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/customid/ent/car/where.go b/entc/integration/customid/ent/car/where.go index 34b304dae..73358463d 100644 --- a/entc/integration/customid/ent/car/where.go +++ b/entc/integration/customid/ent/car/where.go @@ -122,10 +122,11 @@ func ModelIn(vs ...string) predicate.Car { for i := range v { v[i] = vs[i] } + return predicate.Car(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func ModelNotIn(vs ...string) predicate.Car { for i := range v { v[i] = vs[i] } + return predicate.Car(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/card/where.go b/entc/integration/ent/card/where.go index bb7e0b818..1744a79fc 100644 --- a/entc/integration/ent/card/where.go +++ b/entc/integration/ent/card/where.go @@ -145,10 +145,11 @@ func CreateTimeIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -162,10 +163,11 @@ func CreateTimeNotIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -221,10 +223,11 @@ func UpdateTimeIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -238,10 +241,11 @@ func UpdateTimeNotIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -297,10 +301,11 @@ func NumberIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -314,10 +319,11 @@ func NumberNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -408,10 +414,11 @@ func NameIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -425,10 +432,11 @@ func NameNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/comment/where.go b/entc/integration/ent/comment/where.go index 1b92103a7..f5c56d887 100644 --- a/entc/integration/ent/comment/where.go +++ b/entc/integration/ent/comment/where.go @@ -135,10 +135,11 @@ func UniqueIntIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -152,10 +153,11 @@ func UniqueIntNotIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -211,10 +213,11 @@ func UniqueFloatIn(vs ...float64) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -228,10 +231,11 @@ func UniqueFloatNotIn(vs ...float64) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -287,10 +291,11 @@ func NillableIntIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -304,10 +309,11 @@ func NillableIntNotIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/fieldtype/where.go b/entc/integration/ent/fieldtype/where.go index ef77f8f94..fd0da3573 100644 --- a/entc/integration/ent/fieldtype/where.go +++ b/entc/integration/ent/fieldtype/where.go @@ -291,10 +291,11 @@ func IntIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -308,10 +309,11 @@ func IntNotIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -367,10 +369,11 @@ func Int8In(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -384,10 +387,11 @@ func Int8NotIn(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -443,10 +447,11 @@ func Int16In(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -460,10 +465,11 @@ func Int16NotIn(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -519,10 +525,11 @@ func Int32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -536,10 +543,11 @@ func Int32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -595,10 +603,11 @@ func Int64In(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -612,10 +621,11 @@ func Int64NotIn(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -671,10 +681,11 @@ func OptionalIntIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -688,10 +699,11 @@ func OptionalIntNotIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -761,10 +773,11 @@ func OptionalInt8In(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -778,10 +791,11 @@ func OptionalInt8NotIn(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -851,10 +865,11 @@ func OptionalInt16In(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -868,10 +883,11 @@ func OptionalInt16NotIn(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -941,10 +957,11 @@ func OptionalInt32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -958,10 +975,11 @@ func OptionalInt32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1031,10 +1049,11 @@ func OptionalInt64In(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1048,10 +1067,11 @@ func OptionalInt64NotIn(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1121,10 +1141,11 @@ func NillableIntIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1138,10 +1159,11 @@ func NillableIntNotIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1211,10 +1233,11 @@ func NillableInt8In(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1228,10 +1251,11 @@ func NillableInt8NotIn(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1301,10 +1325,11 @@ func NillableInt16In(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1318,10 +1343,11 @@ func NillableInt16NotIn(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1391,10 +1417,11 @@ func NillableInt32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1408,10 +1435,11 @@ func NillableInt32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1481,10 +1509,11 @@ func NillableInt64In(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1498,10 +1527,11 @@ func NillableInt64NotIn(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1571,10 +1601,11 @@ func ValidateOptionalInt32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1588,10 +1619,11 @@ func ValidateOptionalInt32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1661,10 +1693,11 @@ func OptionalUintIn(vs ...uint) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1678,10 +1711,11 @@ func OptionalUintNotIn(vs ...uint) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1751,10 +1785,11 @@ func OptionalUint8In(vs ...uint8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1768,10 +1803,11 @@ func OptionalUint8NotIn(vs ...uint8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1841,10 +1877,11 @@ func OptionalUint16In(vs ...uint16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1858,10 +1895,11 @@ func OptionalUint16NotIn(vs ...uint16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1931,10 +1969,11 @@ func OptionalUint32In(vs ...uint32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1948,10 +1987,11 @@ func OptionalUint32NotIn(vs ...uint32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2021,10 +2061,11 @@ func OptionalUint64In(vs ...uint64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2038,10 +2079,11 @@ func OptionalUint64NotIn(vs ...uint64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2111,10 +2153,11 @@ func StateIn(vs ...State) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2128,10 +2171,11 @@ func StateNotIn(vs ...State) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2173,10 +2217,11 @@ func OptionalFloatIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2190,10 +2235,11 @@ func OptionalFloatNotIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2263,10 +2309,11 @@ func OptionalFloat32In(vs ...float32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2280,10 +2327,11 @@ func OptionalFloat32NotIn(vs ...float32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2353,10 +2401,11 @@ func DatetimeIn(vs ...time.Time) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2370,10 +2419,11 @@ func DatetimeNotIn(vs ...time.Time) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2443,10 +2493,11 @@ func DecimalIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -2460,10 +2511,11 @@ func DecimalNotIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/file/where.go b/entc/integration/ent/file/where.go index 1fc835427..aedfa1663 100644 --- a/entc/integration/ent/file/where.go +++ b/entc/integration/ent/file/where.go @@ -143,10 +143,11 @@ func SizeIn(vs ...int) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -160,10 +161,11 @@ func SizeNotIn(vs ...int) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -219,10 +221,11 @@ func NameIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -236,10 +239,11 @@ func NameNotIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -330,10 +334,11 @@ func UserIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -347,10 +352,11 @@ func UserNotIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -455,10 +461,11 @@ func GroupIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -472,10 +479,11 @@ func GroupNotIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/filetype/where.go b/entc/integration/ent/filetype/where.go index cc2dc792f..fb9c2be8b 100644 --- a/entc/integration/ent/filetype/where.go +++ b/entc/integration/ent/filetype/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.FileType { for i := range v { v[i] = vs[i] } + return predicate.FileType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.FileType { for i := range v { v[i] = vs[i] } + return predicate.FileType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/group/where.go b/entc/integration/ent/group/where.go index 4f9d4ddf2..14ca204c2 100644 --- a/entc/integration/ent/group/where.go +++ b/entc/integration/ent/group/where.go @@ -166,10 +166,11 @@ func ExpireIn(vs ...time.Time) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -183,10 +184,11 @@ func ExpireNotIn(vs ...time.Time) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -242,10 +244,11 @@ func TypeIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -259,10 +262,11 @@ func TypeNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -367,10 +371,11 @@ func MaxUsersIn(vs ...int) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -384,10 +389,11 @@ func MaxUsersNotIn(vs ...int) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -457,10 +463,11 @@ func NameIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -474,10 +481,11 @@ func NameNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/groupinfo/where.go b/entc/integration/ent/groupinfo/where.go index 72aa869ee..0fb0fd016 100644 --- a/entc/integration/ent/groupinfo/where.go +++ b/entc/integration/ent/groupinfo/where.go @@ -129,10 +129,11 @@ func DescIn(vs ...string) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func DescNotIn(vs ...string) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -240,10 +242,11 @@ func MaxUsersIn(vs ...int) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -257,10 +260,11 @@ func MaxUsersNotIn(vs ...int) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/node/where.go b/entc/integration/ent/node/where.go index 0108cf36a..8099c1414 100644 --- a/entc/integration/ent/node/where.go +++ b/entc/integration/ent/node/where.go @@ -122,10 +122,11 @@ func ValueIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func ValueNotIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/pet/where.go b/entc/integration/ent/pet/where.go index 188d8686e..d4469a6f8 100644 --- a/entc/integration/ent/pet/where.go +++ b/entc/integration/ent/pet/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/ent/user/where.go b/entc/integration/ent/user/where.go index ac667aa2b..1b625ec05 100644 --- a/entc/integration/ent/user/where.go +++ b/entc/integration/ent/user/where.go @@ -171,10 +171,11 @@ func OptionalIntIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -188,10 +189,11 @@ func OptionalIntNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -261,10 +263,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -278,10 +281,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -337,10 +341,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -354,10 +359,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -448,10 +454,11 @@ func LastIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -465,10 +472,11 @@ func LastNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -559,10 +567,11 @@ func NicknameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -576,10 +585,11 @@ func NicknameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -684,10 +694,11 @@ func PhoneIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -701,10 +712,11 @@ func PhoneNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -809,10 +821,11 @@ func PasswordIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -826,10 +839,11 @@ func PasswordNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -934,10 +948,11 @@ func RoleIn(vs ...Role) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -951,10 +966,11 @@ func RoleNotIn(vs ...Role) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -982,10 +998,11 @@ func SSOCertIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -999,10 +1016,11 @@ func SSOCertNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/gremlin/ent/card/where.go b/entc/integration/gremlin/ent/card/where.go index 8cb0e34de..6ad740200 100644 --- a/entc/integration/gremlin/ent/card/where.go +++ b/entc/integration/gremlin/ent/card/where.go @@ -134,6 +134,7 @@ func CreateTimeIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldCreateTime, p.Within(v...)) }) @@ -145,6 +146,7 @@ func CreateTimeNotIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldCreateTime, p.Without(v...)) }) @@ -198,6 +200,7 @@ func UpdateTimeIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldUpdateTime, p.Within(v...)) }) @@ -209,6 +212,7 @@ func UpdateTimeNotIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldUpdateTime, p.Without(v...)) }) @@ -262,6 +266,7 @@ func NumberIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldNumber, p.Within(v...)) }) @@ -273,6 +278,7 @@ func NumberNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldNumber, p.Without(v...)) }) @@ -347,6 +353,7 @@ func NameIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Within(v...)) }) @@ -358,6 +365,7 @@ func NameNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/comment/where.go b/entc/integration/gremlin/ent/comment/where.go index 94831c17f..1e90a5ca0 100644 --- a/entc/integration/gremlin/ent/comment/where.go +++ b/entc/integration/gremlin/ent/comment/where.go @@ -125,6 +125,7 @@ func UniqueIntIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(t *dsl.Traversal) { t.Has(Label, FieldUniqueInt, p.Within(v...)) }) @@ -136,6 +137,7 @@ func UniqueIntNotIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(t *dsl.Traversal) { t.Has(Label, FieldUniqueInt, p.Without(v...)) }) @@ -189,6 +191,7 @@ func UniqueFloatIn(vs ...float64) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(t *dsl.Traversal) { t.Has(Label, FieldUniqueFloat, p.Within(v...)) }) @@ -200,6 +203,7 @@ func UniqueFloatNotIn(vs ...float64) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(t *dsl.Traversal) { t.Has(Label, FieldUniqueFloat, p.Without(v...)) }) @@ -253,6 +257,7 @@ func NillableIntIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt, p.Within(v...)) }) @@ -264,6 +269,7 @@ func NillableIntNotIn(vs ...int) predicate.Comment { for i := range v { v[i] = vs[i] } + return predicate.Comment(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/fieldtype/where.go b/entc/integration/gremlin/ent/fieldtype/where.go index a921fbb97..40afab55f 100644 --- a/entc/integration/gremlin/ent/fieldtype/where.go +++ b/entc/integration/gremlin/ent/fieldtype/where.go @@ -281,6 +281,7 @@ func IntIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt, p.Within(v...)) }) @@ -292,6 +293,7 @@ func IntNotIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt, p.Without(v...)) }) @@ -345,6 +347,7 @@ func Int8In(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt8, p.Within(v...)) }) @@ -356,6 +359,7 @@ func Int8NotIn(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt8, p.Without(v...)) }) @@ -409,6 +413,7 @@ func Int16In(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt16, p.Within(v...)) }) @@ -420,6 +425,7 @@ func Int16NotIn(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt16, p.Without(v...)) }) @@ -473,6 +479,7 @@ func Int32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt32, p.Within(v...)) }) @@ -484,6 +491,7 @@ func Int32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt32, p.Without(v...)) }) @@ -537,6 +545,7 @@ func Int64In(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt64, p.Within(v...)) }) @@ -548,6 +557,7 @@ func Int64NotIn(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldInt64, p.Without(v...)) }) @@ -601,6 +611,7 @@ func OptionalIntIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt, p.Within(v...)) }) @@ -612,6 +623,7 @@ func OptionalIntNotIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt, p.Without(v...)) }) @@ -679,6 +691,7 @@ func OptionalInt8In(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt8, p.Within(v...)) }) @@ -690,6 +703,7 @@ func OptionalInt8NotIn(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt8, p.Without(v...)) }) @@ -757,6 +771,7 @@ func OptionalInt16In(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt16, p.Within(v...)) }) @@ -768,6 +783,7 @@ func OptionalInt16NotIn(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt16, p.Without(v...)) }) @@ -835,6 +851,7 @@ func OptionalInt32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt32, p.Within(v...)) }) @@ -846,6 +863,7 @@ func OptionalInt32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt32, p.Without(v...)) }) @@ -913,6 +931,7 @@ func OptionalInt64In(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt64, p.Within(v...)) }) @@ -924,6 +943,7 @@ func OptionalInt64NotIn(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt64, p.Without(v...)) }) @@ -991,6 +1011,7 @@ func NillableIntIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt, p.Within(v...)) }) @@ -1002,6 +1023,7 @@ func NillableIntNotIn(vs ...int) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt, p.Without(v...)) }) @@ -1069,6 +1091,7 @@ func NillableInt8In(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt8, p.Within(v...)) }) @@ -1080,6 +1103,7 @@ func NillableInt8NotIn(vs ...int8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt8, p.Without(v...)) }) @@ -1147,6 +1171,7 @@ func NillableInt16In(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt16, p.Within(v...)) }) @@ -1158,6 +1183,7 @@ func NillableInt16NotIn(vs ...int16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt16, p.Without(v...)) }) @@ -1225,6 +1251,7 @@ func NillableInt32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt32, p.Within(v...)) }) @@ -1236,6 +1263,7 @@ func NillableInt32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt32, p.Without(v...)) }) @@ -1303,6 +1331,7 @@ func NillableInt64In(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt64, p.Within(v...)) }) @@ -1314,6 +1343,7 @@ func NillableInt64NotIn(vs ...int64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldNillableInt64, p.Without(v...)) }) @@ -1381,6 +1411,7 @@ func ValidateOptionalInt32In(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldValidateOptionalInt32, p.Within(v...)) }) @@ -1392,6 +1423,7 @@ func ValidateOptionalInt32NotIn(vs ...int32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldValidateOptionalInt32, p.Without(v...)) }) @@ -1459,6 +1491,7 @@ func OptionalUintIn(vs ...uint) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint, p.Within(v...)) }) @@ -1470,6 +1503,7 @@ func OptionalUintNotIn(vs ...uint) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint, p.Without(v...)) }) @@ -1537,6 +1571,7 @@ func OptionalUint8In(vs ...uint8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint8, p.Within(v...)) }) @@ -1548,6 +1583,7 @@ func OptionalUint8NotIn(vs ...uint8) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint8, p.Without(v...)) }) @@ -1615,6 +1651,7 @@ func OptionalUint16In(vs ...uint16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint16, p.Within(v...)) }) @@ -1626,6 +1663,7 @@ func OptionalUint16NotIn(vs ...uint16) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint16, p.Without(v...)) }) @@ -1693,6 +1731,7 @@ func OptionalUint32In(vs ...uint32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint32, p.Within(v...)) }) @@ -1704,6 +1743,7 @@ func OptionalUint32NotIn(vs ...uint32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint32, p.Without(v...)) }) @@ -1771,6 +1811,7 @@ func OptionalUint64In(vs ...uint64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint64, p.Within(v...)) }) @@ -1782,6 +1823,7 @@ func OptionalUint64NotIn(vs ...uint64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalUint64, p.Without(v...)) }) @@ -1849,6 +1891,7 @@ func StateIn(vs ...State) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldState, p.Within(v...)) }) @@ -1860,6 +1903,7 @@ func StateNotIn(vs ...State) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldState, p.Without(v...)) }) @@ -1899,6 +1943,7 @@ func OptionalFloatIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalFloat, p.Within(v...)) }) @@ -1910,6 +1955,7 @@ func OptionalFloatNotIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalFloat, p.Without(v...)) }) @@ -1977,6 +2023,7 @@ func OptionalFloat32In(vs ...float32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalFloat32, p.Within(v...)) }) @@ -1988,6 +2035,7 @@ func OptionalFloat32NotIn(vs ...float32) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalFloat32, p.Without(v...)) }) @@ -2055,6 +2103,7 @@ func DatetimeIn(vs ...time.Time) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldDatetime, p.Within(v...)) }) @@ -2066,6 +2115,7 @@ func DatetimeNotIn(vs ...time.Time) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldDatetime, p.Without(v...)) }) @@ -2133,6 +2183,7 @@ func DecimalIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldDecimal, p.Within(v...)) }) @@ -2144,6 +2195,7 @@ func DecimalNotIn(vs ...float64) predicate.FieldType { for i := range v { v[i] = vs[i] } + return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldDecimal, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/file/where.go b/entc/integration/gremlin/ent/file/where.go index a78d04d6d..b9495e5c0 100644 --- a/entc/integration/gremlin/ent/file/where.go +++ b/entc/integration/gremlin/ent/file/where.go @@ -132,6 +132,7 @@ func SizeIn(vs ...int) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldSize, p.Within(v...)) }) @@ -143,6 +144,7 @@ func SizeNotIn(vs ...int) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldSize, p.Without(v...)) }) @@ -196,6 +198,7 @@ func NameIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Within(v...)) }) @@ -207,6 +210,7 @@ func NameNotIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Without(v...)) }) @@ -281,6 +285,7 @@ func UserIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldUser, p.Within(v...)) }) @@ -292,6 +297,7 @@ func UserNotIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldUser, p.Without(v...)) }) @@ -380,6 +386,7 @@ func GroupIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldGroup, p.Within(v...)) }) @@ -391,6 +398,7 @@ func GroupNotIn(vs ...string) predicate.File { for i := range v { v[i] = vs[i] } + return predicate.File(func(t *dsl.Traversal) { t.Has(Label, FieldGroup, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/filetype/where.go b/entc/integration/gremlin/ent/filetype/where.go index 56e881702..0d1b0b983 100644 --- a/entc/integration/gremlin/ent/filetype/where.go +++ b/entc/integration/gremlin/ent/filetype/where.go @@ -111,6 +111,7 @@ func NameIn(vs ...string) predicate.FileType { for i := range v { v[i] = vs[i] } + return predicate.FileType(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Within(v...)) }) @@ -122,6 +123,7 @@ func NameNotIn(vs ...string) predicate.FileType { for i := range v { v[i] = vs[i] } + return predicate.FileType(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/group/where.go b/entc/integration/gremlin/ent/group/where.go index 3bc4c819d..79f931776 100644 --- a/entc/integration/gremlin/ent/group/where.go +++ b/entc/integration/gremlin/ent/group/where.go @@ -155,6 +155,7 @@ func ExpireIn(vs ...time.Time) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldExpire, p.Within(v...)) }) @@ -166,6 +167,7 @@ func ExpireNotIn(vs ...time.Time) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldExpire, p.Without(v...)) }) @@ -219,6 +221,7 @@ func TypeIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldType, p.Within(v...)) }) @@ -230,6 +233,7 @@ func TypeNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldType, p.Without(v...)) }) @@ -318,6 +322,7 @@ func MaxUsersIn(vs ...int) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldMaxUsers, p.Within(v...)) }) @@ -329,6 +334,7 @@ func MaxUsersNotIn(vs ...int) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldMaxUsers, p.Without(v...)) }) @@ -396,6 +402,7 @@ func NameIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Within(v...)) }) @@ -407,6 +414,7 @@ func NameNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/groupinfo/where.go b/entc/integration/gremlin/ent/groupinfo/where.go index 77e8f9ae4..89333a448 100644 --- a/entc/integration/gremlin/ent/groupinfo/where.go +++ b/entc/integration/gremlin/ent/groupinfo/where.go @@ -118,6 +118,7 @@ func DescIn(vs ...string) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(t *dsl.Traversal) { t.Has(Label, FieldDesc, p.Within(v...)) }) @@ -129,6 +130,7 @@ func DescNotIn(vs ...string) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(t *dsl.Traversal) { t.Has(Label, FieldDesc, p.Without(v...)) }) @@ -203,6 +205,7 @@ func MaxUsersIn(vs ...int) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(t *dsl.Traversal) { t.Has(Label, FieldMaxUsers, p.Within(v...)) }) @@ -214,6 +217,7 @@ func MaxUsersNotIn(vs ...int) predicate.GroupInfo { for i := range v { v[i] = vs[i] } + return predicate.GroupInfo(func(t *dsl.Traversal) { t.Has(Label, FieldMaxUsers, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/node/where.go b/entc/integration/gremlin/ent/node/where.go index b409b5366..97078ac8c 100644 --- a/entc/integration/gremlin/ent/node/where.go +++ b/entc/integration/gremlin/ent/node/where.go @@ -111,6 +111,7 @@ func ValueIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(t *dsl.Traversal) { t.Has(Label, FieldValue, p.Within(v...)) }) @@ -122,6 +123,7 @@ func ValueNotIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(t *dsl.Traversal) { t.Has(Label, FieldValue, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/pet/where.go b/entc/integration/gremlin/ent/pet/where.go index a996ef643..681752a87 100644 --- a/entc/integration/gremlin/ent/pet/where.go +++ b/entc/integration/gremlin/ent/pet/where.go @@ -111,6 +111,7 @@ func NameIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Within(v...)) }) @@ -122,6 +123,7 @@ func NameNotIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Without(v...)) }) diff --git a/entc/integration/gremlin/ent/user/where.go b/entc/integration/gremlin/ent/user/where.go index 67ec66144..b09129b03 100644 --- a/entc/integration/gremlin/ent/user/where.go +++ b/entc/integration/gremlin/ent/user/where.go @@ -160,6 +160,7 @@ func OptionalIntIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt, p.Within(v...)) }) @@ -171,6 +172,7 @@ func OptionalIntNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldOptionalInt, p.Without(v...)) }) @@ -238,6 +240,7 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldAge, p.Within(v...)) }) @@ -249,6 +252,7 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldAge, p.Without(v...)) }) @@ -302,6 +306,7 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Within(v...)) }) @@ -313,6 +318,7 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldName, p.Without(v...)) }) @@ -387,6 +393,7 @@ func LastIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldLast, p.Within(v...)) }) @@ -398,6 +405,7 @@ func LastNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldLast, p.Without(v...)) }) @@ -472,6 +480,7 @@ func NicknameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldNickname, p.Within(v...)) }) @@ -483,6 +492,7 @@ func NicknameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldNickname, p.Without(v...)) }) @@ -571,6 +581,7 @@ func PhoneIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldPhone, p.Within(v...)) }) @@ -582,6 +593,7 @@ func PhoneNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldPhone, p.Without(v...)) }) @@ -670,6 +682,7 @@ func PasswordIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldPassword, p.Within(v...)) }) @@ -681,6 +694,7 @@ func PasswordNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldPassword, p.Without(v...)) }) @@ -769,6 +783,7 @@ func RoleIn(vs ...Role) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldRole, p.Within(v...)) }) @@ -780,6 +795,7 @@ func RoleNotIn(vs ...Role) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldRole, p.Without(v...)) }) @@ -805,6 +821,7 @@ func SSOCertIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldSSOCert, p.Within(v...)) }) @@ -816,6 +833,7 @@ func SSOCertNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(t *dsl.Traversal) { t.Has(Label, FieldSSOCert, p.Without(v...)) }) diff --git a/entc/integration/hooks/ent/card/where.go b/entc/integration/hooks/ent/card/where.go index c2dded62e..81f118ffb 100644 --- a/entc/integration/hooks/ent/card/where.go +++ b/entc/integration/hooks/ent/card/where.go @@ -138,10 +138,11 @@ func NumberIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -155,10 +156,11 @@ func NumberNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -249,10 +251,11 @@ func NameIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -266,10 +269,11 @@ func NameNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -374,10 +378,11 @@ func CreatedAtIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -391,10 +396,11 @@ func CreatedAtNotIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/hooks/ent/user/where.go b/entc/integration/hooks/ent/user/where.go index fe0979f92..9c2e08b31 100644 --- a/entc/integration/hooks/ent/user/where.go +++ b/entc/integration/hooks/ent/user/where.go @@ -129,10 +129,11 @@ func VersionIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func VersionNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/idtype/ent/user/where.go b/entc/integration/idtype/ent/user/where.go index aa1fac566..337c72a13 100644 --- a/entc/integration/idtype/ent/user/where.go +++ b/entc/integration/idtype/ent/user/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/migrate/entv1/user/where.go b/entc/integration/migrate/entv1/user/where.go index 6070dd54e..06a601bc6 100644 --- a/entc/integration/migrate/entv1/user/where.go +++ b/entc/integration/migrate/entv1/user/where.go @@ -157,10 +157,11 @@ func AgeIn(vs ...int32) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -174,10 +175,11 @@ func AgeNotIn(vs ...int32) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -233,10 +235,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -250,10 +253,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -344,10 +348,11 @@ func NicknameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -361,10 +366,11 @@ func NicknameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -455,10 +461,11 @@ func AddressIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -472,10 +479,11 @@ func AddressNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -580,10 +588,11 @@ func RenamedIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -597,10 +606,11 @@ func RenamedNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -705,10 +715,11 @@ func BlobIn(vs ...[]byte) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -722,10 +733,11 @@ func BlobNotIn(vs ...[]byte) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -795,10 +807,11 @@ func StateIn(vs ...State) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -812,10 +825,11 @@ func StateNotIn(vs ...State) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/migrate/entv2/user/where.go b/entc/integration/migrate/entv2/user/where.go index a12290ac5..d94e00fab 100644 --- a/entc/integration/migrate/entv2/user/where.go +++ b/entc/integration/migrate/entv2/user/where.go @@ -171,10 +171,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -188,10 +189,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -247,10 +249,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -264,10 +267,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -358,10 +362,11 @@ func NicknameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -375,10 +380,11 @@ func NicknameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -469,10 +475,11 @@ func PhoneIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -486,10 +493,11 @@ func PhoneNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -580,10 +588,11 @@ func BufferIn(vs ...[]byte) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -597,10 +606,11 @@ func BufferNotIn(vs ...[]byte) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -670,10 +680,11 @@ func TitleIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -687,10 +698,11 @@ func TitleNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -781,10 +793,11 @@ func NewNameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -798,10 +811,11 @@ func NewNameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -906,10 +920,11 @@ func BlobIn(vs ...[]byte) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -923,10 +938,11 @@ func BlobNotIn(vs ...[]byte) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -996,10 +1012,11 @@ func StateIn(vs ...State) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -1013,10 +1030,11 @@ func StateNotIn(vs ...State) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/privacy/ent/galaxy/where.go b/entc/integration/privacy/ent/galaxy/where.go index 96ecd4738..4c3ec100f 100644 --- a/entc/integration/privacy/ent/galaxy/where.go +++ b/entc/integration/privacy/ent/galaxy/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Galaxy { for i := range v { v[i] = vs[i] } + return predicate.Galaxy(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Galaxy { for i := range v { v[i] = vs[i] } + return predicate.Galaxy(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -233,10 +235,11 @@ func TypeIn(vs ...Type) predicate.Galaxy { for i := range v { v[i] = vs[i] } + return predicate.Galaxy(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -250,10 +253,11 @@ func TypeNotIn(vs ...Type) predicate.Galaxy { for i := range v { v[i] = vs[i] } + return predicate.Galaxy(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/privacy/ent/planet/where.go b/entc/integration/privacy/ent/planet/where.go index 2d2f944e4..d7a3ec0e9 100644 --- a/entc/integration/privacy/ent/planet/where.go +++ b/entc/integration/privacy/ent/planet/where.go @@ -129,10 +129,11 @@ func NameIn(vs ...string) predicate.Planet { for i := range v { v[i] = vs[i] } + return predicate.Planet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func NameNotIn(vs ...string) predicate.Planet { for i := range v { v[i] = vs[i] } + return predicate.Planet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -240,10 +242,11 @@ func AgeIn(vs ...uint) predicate.Planet { for i := range v { v[i] = vs[i] } + return predicate.Planet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -257,10 +260,11 @@ func AgeNotIn(vs ...uint) predicate.Planet { for i := range v { v[i] = vs[i] } + return predicate.Planet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/template/ent/group/where.go b/entc/integration/template/ent/group/where.go index d26c77b85..0640eb830 100644 --- a/entc/integration/template/ent/group/where.go +++ b/entc/integration/template/ent/group/where.go @@ -121,10 +121,11 @@ func MaxUsersIn(vs ...int) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -138,10 +139,11 @@ func MaxUsersNotIn(vs ...int) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/template/ent/pet/where.go b/entc/integration/template/ent/pet/where.go index c7ad14a50..3cf2c00cd 100644 --- a/entc/integration/template/ent/pet/where.go +++ b/entc/integration/template/ent/pet/where.go @@ -131,10 +131,11 @@ func AgeIn(vs ...int) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -148,10 +149,11 @@ func AgeNotIn(vs ...int) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -207,10 +209,11 @@ func LicensedAtIn(vs ...time.Time) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -224,10 +227,11 @@ func LicensedAtNotIn(vs ...time.Time) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/entc/integration/template/ent/user/where.go b/entc/integration/template/ent/user/where.go index 71aae5a1b..3868a2cc1 100644 --- a/entc/integration/template/ent/user/where.go +++ b/entc/integration/template/ent/user/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/edgeindex/ent/city/where.go b/examples/edgeindex/ent/city/where.go index a3e940975..9178eb69d 100644 --- a/examples/edgeindex/ent/city/where.go +++ b/examples/edgeindex/ent/city/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.City { for i := range v { v[i] = vs[i] } + return predicate.City(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.City { for i := range v { v[i] = vs[i] } + return predicate.City(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/edgeindex/ent/street/where.go b/examples/edgeindex/ent/street/where.go index 2c9875bfc..b4edd7583 100644 --- a/examples/edgeindex/ent/street/where.go +++ b/examples/edgeindex/ent/street/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Street { for i := range v { v[i] = vs[i] } + return predicate.Street(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Street { for i := range v { v[i] = vs[i] } + return predicate.Street(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/m2m2types/ent/group/where.go b/examples/m2m2types/ent/group/where.go index fd2855bd8..ca090e37e 100644 --- a/examples/m2m2types/ent/group/where.go +++ b/examples/m2m2types/ent/group/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/m2m2types/ent/user/where.go b/examples/m2m2types/ent/user/where.go index 174961a2c..2f29079d6 100644 --- a/examples/m2m2types/ent/user/where.go +++ b/examples/m2m2types/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/m2mbidi/ent/user/where.go b/examples/m2mbidi/ent/user/where.go index 36fa96485..543f8c895 100644 --- a/examples/m2mbidi/ent/user/where.go +++ b/examples/m2mbidi/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/m2mrecur/ent/user/where.go b/examples/m2mrecur/ent/user/where.go index 18b3b3849..a0f2d17db 100644 --- a/examples/m2mrecur/ent/user/where.go +++ b/examples/m2mrecur/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2m2types/ent/pet/where.go b/examples/o2m2types/ent/pet/where.go index fa57c946b..b6be17920 100644 --- a/examples/o2m2types/ent/pet/where.go +++ b/examples/o2m2types/ent/pet/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2m2types/ent/user/where.go b/examples/o2m2types/ent/user/where.go index 05efa86a9..06caf41b1 100644 --- a/examples/o2m2types/ent/user/where.go +++ b/examples/o2m2types/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2mrecur/ent/node/where.go b/examples/o2mrecur/ent/node/where.go index be36908aa..c93bd90b2 100644 --- a/examples/o2mrecur/ent/node/where.go +++ b/examples/o2mrecur/ent/node/where.go @@ -122,10 +122,11 @@ func ValueIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func ValueNotIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2o2types/ent/card/where.go b/examples/o2o2types/ent/card/where.go index 91f12b100..4bd90dfca 100644 --- a/examples/o2o2types/ent/card/where.go +++ b/examples/o2o2types/ent/card/where.go @@ -131,10 +131,11 @@ func ExpiredIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -148,10 +149,11 @@ func ExpiredNotIn(vs ...time.Time) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -207,10 +209,11 @@ func NumberIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -224,10 +227,11 @@ func NumberNotIn(vs ...string) predicate.Card { for i := range v { v[i] = vs[i] } + return predicate.Card(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2o2types/ent/user/where.go b/examples/o2o2types/ent/user/where.go index cf61b912a..a6d40a557 100644 --- a/examples/o2o2types/ent/user/where.go +++ b/examples/o2o2types/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2obidi/ent/user/where.go b/examples/o2obidi/ent/user/where.go index c5f070dd7..cbd330144 100644 --- a/examples/o2obidi/ent/user/where.go +++ b/examples/o2obidi/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/o2orecur/ent/node/where.go b/examples/o2orecur/ent/node/where.go index b61f0dd95..d1b245652 100644 --- a/examples/o2orecur/ent/node/where.go +++ b/examples/o2orecur/ent/node/where.go @@ -122,10 +122,11 @@ func ValueIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func ValueNotIn(vs ...int) predicate.Node { for i := range v { v[i] = vs[i] } + return predicate.Node(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/start/ent/car/where.go b/examples/start/ent/car/where.go index 96b1b4692..eebc32f9b 100644 --- a/examples/start/ent/car/where.go +++ b/examples/start/ent/car/where.go @@ -131,10 +131,11 @@ func ModelIn(vs ...string) predicate.Car { for i := range v { v[i] = vs[i] } + return predicate.Car(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -148,10 +149,11 @@ func ModelNotIn(vs ...string) predicate.Car { for i := range v { v[i] = vs[i] } + return predicate.Car(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -242,10 +244,11 @@ func RegisteredAtIn(vs ...time.Time) predicate.Car { for i := range v { v[i] = vs[i] } + return predicate.Car(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -259,10 +262,11 @@ func RegisteredAtNotIn(vs ...time.Time) predicate.Car { for i := range v { v[i] = vs[i] } + return predicate.Car(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/start/ent/group/where.go b/examples/start/ent/group/where.go index 50e8df451..dda3e9069 100644 --- a/examples/start/ent/group/where.go +++ b/examples/start/ent/group/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/start/ent/user/where.go b/examples/start/ent/user/where.go index da29beb22..f8df75803 100644 --- a/examples/start/ent/user/where.go +++ b/examples/start/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/traversal/ent/group/where.go b/examples/traversal/ent/group/where.go index 710028d25..952189e55 100644 --- a/examples/traversal/ent/group/where.go +++ b/examples/traversal/ent/group/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Group { for i := range v { v[i] = vs[i] } + return predicate.Group(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/traversal/ent/pet/where.go b/examples/traversal/ent/pet/where.go index e5e3d3155..ce03c2998 100644 --- a/examples/traversal/ent/pet/where.go +++ b/examples/traversal/ent/pet/where.go @@ -122,10 +122,11 @@ func NameIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -139,10 +140,11 @@ func NameNotIn(vs ...string) predicate.Pet { for i := range v { v[i] = vs[i] } + return predicate.Pet(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/examples/traversal/ent/user/where.go b/examples/traversal/ent/user/where.go index 2ab62b2b1..782d133d3 100644 --- a/examples/traversal/ent/user/where.go +++ b/examples/traversal/ent/user/where.go @@ -129,10 +129,11 @@ func AgeIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -146,10 +147,11 @@ func AgeNotIn(vs ...int) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -205,10 +207,11 @@ func NameIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } @@ -222,10 +225,11 @@ func NameNotIn(vs ...string) predicate.User { for i := range v { v[i] = vs[i] } + return predicate.User(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { + if len(v) == 0 { s.Where(sql.False()) return } diff --git a/schema/field/field.go b/schema/field/field.go index 7a9d96bc2..888b7a38e 100644 --- a/schema/field/field.go +++ b/schema/field/field.go @@ -5,6 +5,7 @@ package field import ( + "database/sql" "database/sql/driver" "errors" "fmt" @@ -14,31 +15,6 @@ import ( "time" ) -// A Descriptor for field configuration. -type Descriptor struct { - Tag string // struct tag. - Size int // varchar size. - Name string // field name. - Info *TypeInfo // field type info. - Unique bool // unique index of field. - Nillable bool // nillable struct field. - Optional bool // nullable field in database. - Immutable bool // create-only field. - Default interface{} // default value on create. - UpdateDefault interface{} // default value on update. - Validators []interface{} // validator functions. - StorageKey string // sql column or gremlin property. - Enums []string // enum values. - Sensitive bool // sensitive info string field. - SchemaType map[string]string // override the schema type. - err error -} - -// Err returns the error, if any, that was added by the field builder. -func (d *Descriptor) Err() error { - return d.err -} - // String returns a new Field with type string. func String(name string) *stringBuilder { return &stringBuilder{&Descriptor{ @@ -280,6 +256,16 @@ func (b *stringBuilder) SchemaType(types map[string]string) *stringBuilder { return b } +// GoType overrides the default Go type with a custom one. +// +// field.String("dir"). +// GoType(http.Dir("dir")) +// +func (b *stringBuilder) GoType(typ interface{}) *stringBuilder { + b.desc.goType(typ, reflect.String) + return b +} + // Descriptor implements the ent.Field interface by returning its descriptor. func (b *stringBuilder) Descriptor() *Descriptor { return b.desc @@ -697,3 +683,86 @@ func (b *uuidBuilder) SchemaType(types map[string]string) *uuidBuilder { func (b *uuidBuilder) Descriptor() *Descriptor { return b.desc } + +// A Descriptor for field configuration. +type Descriptor struct { + Tag string // struct tag. + Size int // varchar size. + Name string // field name. + Info *TypeInfo // field type info. + Unique bool // unique index of field. + Nillable bool // nillable struct field. + Optional bool // nullable field in database. + Immutable bool // create-only field. + Default interface{} // default value on create. + UpdateDefault interface{} // default value on update. + Validators []interface{} // validator functions. + StorageKey string // sql column or gremlin property. + Enums []string // enum values. + Sensitive bool // sensitive info string field. + SchemaType map[string]string // override the schema type. + err error +} + +// Err returns the error, if any, that was added by the field builder. +func (d *Descriptor) Err() error { + return d.err +} + +func (d *Descriptor) goType(typ interface{}, expectKind reflect.Kind) { + t := reflect.TypeOf(typ) + tv := indirect(t) + info := &TypeInfo{ + Type: TypeString, + Ident: t.String(), + PkgPath: tv.PkgPath(), + RType: &RType{ + Name: tv.Name(), + Kind: tv.Kind(), + PkgPath: tv.PkgPath(), + Methods: make(map[string]struct{ In, Out []*RType }, t.NumMethod()), + }, + } + switch t.Kind() { + case reflect.Slice, reflect.Array, reflect.Ptr, reflect.Map: + info.Nillable = true + } + switch { + case tv.Kind() == expectKind: + case t.Implements(valueScannerType): + n := t.NumMethod() + for i := 0; i < n; i++ { + m := t.Method(i) + in := make([]*RType, m.Type.NumIn()-1) + for j := range in { + arg := m.Type.In(j + 1) + in[j] = &RType{Name: arg.Name(), Kind: arg.Kind(), PkgPath: arg.PkgPath()} + } + out := make([]*RType, m.Type.NumOut()) + for j := range out { + ret := m.Type.Out(j) + out[j] = &RType{Name: ret.Name(), Kind: ret.Kind(), PkgPath: ret.PkgPath()} + } + info.RType.Methods[m.Name] = struct{ In, Out []*RType }{in, out} + } + default: + d.err = fmt.Errorf("GoType must be a %q type or ValueScanner", expectKind) + } + d.Info = info +} + +var valueScannerType = reflect.TypeOf((*ValueScanner)(nil)).Elem() + +// ValueScanner is the interface that groups the Value and the Scan methods. +type ValueScanner interface { + driver.Valuer + sql.Scanner +} + +// indirect returns the type at the end of indirection. +func indirect(t reflect.Type) reflect.Type { + for t.Kind() == reflect.Ptr { + t = t.Elem() + } + return t +} diff --git a/schema/field/field_test.go b/schema/field/field_test.go index d4d31ed6e..70116455b 100644 --- a/schema/field/field_test.go +++ b/schema/field/field_test.go @@ -5,7 +5,10 @@ package field_test import ( + "database/sql" "net/http" + "net/url" + "reflect" "regexp" "testing" "time" @@ -101,6 +104,48 @@ func TestString(t *testing.T) { assert.True(t, fd.Unique) assert.Len(t, fd.Validators, 2) assert.True(t, fd.Sensitive) + + fd = field.String("name").GoType(http.Dir("dir")).Descriptor() + assert.NoError(t, fd.Err()) + assert.Equal(t, "http.Dir", fd.Info.Ident) + assert.Equal(t, "net/http", fd.Info.PkgPath) + assert.Equal(t, "http.Dir", fd.Info.String()) + assert.False(t, fd.Info.Nillable) + assert.False(t, fd.Info.ValueScanner()) + + fd = field.String("name").GoType(http.MethodOptions).Descriptor() + assert.NoError(t, fd.Err()) + assert.Equal(t, "string", fd.Info.Ident) + assert.Equal(t, "", fd.Info.PkgPath) + assert.Equal(t, "string", fd.Info.String()) + assert.False(t, fd.Info.Nillable) + + fd = field.String("nullable_name").GoType(&sql.NullString{}).Descriptor() + assert.NoError(t, fd.Err()) + assert.Equal(t, "*sql.NullString", fd.Info.Ident) + assert.Equal(t, "database/sql", fd.Info.PkgPath) + assert.Equal(t, "*sql.NullString", fd.Info.String()) + assert.True(t, fd.Info.Nillable) + assert.True(t, fd.Info.ValueScanner()) + assert.False(t, fd.Info.Stringer()) + assert.True(t, fd.Info.RType.TypeEqual(reflect.TypeOf(sql.NullString{}))) + assert.True(t, fd.Info.RType.TypeEqual(reflect.TypeOf(&sql.NullString{}))) + + type tURL struct { + field.ValueScanner + *url.URL + } + fd = field.String("nullable_url").GoType(&tURL{}).Descriptor() + assert.Equal(t, "*field_test.tURL", fd.Info.Ident) + assert.Equal(t, "github.com/facebookincubator/ent/schema/field_test", fd.Info.PkgPath) + assert.Equal(t, "*field_test.tURL", fd.Info.String()) + assert.True(t, fd.Info.ValueScanner()) + assert.True(t, fd.Info.Stringer()) + + fd = field.String("name").GoType(1).Descriptor() + assert.Error(t, fd.Err()) + fd = field.String("name").GoType(struct{}{}).Descriptor() + assert.Error(t, fd.Err()) } func TestTime(t *testing.T) { diff --git a/schema/field/type.go b/schema/field/type.go index 26615f529..7016c1c6f 100644 --- a/schema/field/type.go +++ b/schema/field/type.go @@ -4,7 +4,11 @@ package field -import "strings" +import ( + "fmt" + "reflect" + "strings" +) // A Type represents a field type. type Type uint8 @@ -72,6 +76,7 @@ type TypeInfo struct { Ident string PkgPath string Nillable bool // slices or pointers. + RType *RType } // String returns the string representation of a type. @@ -101,6 +106,18 @@ func (t TypeInfo) ConstName() string { return t.Type.ConstName() } +// ValueScanner indicates if this type implements the ValueScanner interface. +func (t TypeInfo) ValueScanner() bool { + return t.RType.implements(valueScannerType) +} + +var stringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() + +// Stringer indicates if this type implements the Stringer interface. +func (t TypeInfo) Stringer() bool { + return t.RType.implements(stringerType) +} + var ( typeNames = [...]string{ TypeInvalid: "invalid", @@ -132,3 +149,45 @@ var ( TypeBytes: "TypeBytes", } ) + +// RType holds a serializable reflect.Type information of +// Go object. Used by the entc package. +type RType struct { + Name string + Kind reflect.Kind + PkgPath string + Methods map[string]struct{ In, Out []*RType } +} + +// TypeEqual tests if the RType is equal to given reflect.Type. +func (r *RType) TypeEqual(t reflect.Type) bool { + t = indirect(t) + return r.Name == t.Name() && r.Kind == t.Kind() && r.PkgPath == t.PkgPath() +} + +func (r *RType) implements(typ reflect.Type) bool { + if r == nil { + return false + } + n := typ.NumMethod() + for i := 0; i < n; i++ { + m0 := typ.Method(i) + m1, ok := r.Methods[m0.Name] + if !ok || len(m1.In) != m0.Type.NumIn() || len(m1.Out) != m0.Type.NumOut() { + return false + } + in := m0.Type.NumIn() + for j := 0; j < in; j++ { + if !m1.In[j].TypeEqual(m0.Type.In(j)) { + return false + } + } + out := m0.Type.NumOut() + for j := 0; j < out; j++ { + if !m1.Out[j].TypeEqual(m0.Type.Out(j)) { + return false + } + } + } + return true +}