From bf566aa3ac30f3a056c5423929461eef82b82098 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Thu, 28 May 2020 18:23:14 +0300 Subject: [PATCH] entc/gen: support valuescanner in go-types (#510) --- entc/gen/func.go | 8 + entc/gen/internal/bindata.go | 12 +- entc/gen/storage.go | 6 +- entc/gen/template/dialect/sql/decode.tmpl | 2 +- entc/gen/template/import.tmpl | 5 +- entc/gen/template/where.tmpl | 10 +- entc/gen/type.go | 9 + entc/integration/ent/fieldtype.go | 49 +- entc/integration/ent/fieldtype/fieldtype.go | 10 +- entc/integration/ent/fieldtype/where.go | 585 ++++++++++++++++- entc/integration/ent/fieldtype_create.go | 58 ++ entc/integration/ent/fieldtype_update.go | 201 ++++++ entc/integration/ent/migrate/schema.go | 6 +- entc/integration/ent/mutation.go | 300 ++++++++- entc/integration/ent/schema/fieldtype.go | 44 ++ entc/integration/gremlin/ent/fieldtype.go | 48 ++ .../gremlin/ent/fieldtype/fieldtype.go | 7 +- .../gremlin/ent/fieldtype/where.go | 586 +++++++++++++++++- .../gremlin/ent/fieldtype_create.go | 55 ++ .../gremlin/ent/fieldtype_update.go | 198 ++++++ entc/integration/gremlin/ent/mutation.go | 374 ++++++++++- entc/integration/type_test.go | 31 +- schema/field/field.go | 2 +- schema/field/field_test.go | 8 +- 24 files changed, 2580 insertions(+), 34 deletions(-) diff --git a/entc/gen/func.go b/entc/gen/func.go index 95a259860..d27598821 100644 --- a/entc/gen/func.go +++ b/entc/gen/func.go @@ -46,6 +46,7 @@ var ( "lower": strings.ToLower, "upper": strings.ToUpper, "hasField": hasField, + "hasImport": hasImport, "indirect": indirect, "hasPrefix": strings.HasPrefix, "hasSuffix": strings.HasSuffix, @@ -69,6 +70,7 @@ var ( // ops returns all operations for given field. func ops(f *Field) (op []Op) { switch t := f.Type.Type; { + case f.HasGoType() && !f.ConvertedToBasic(): case t == field.TypeJSON: case t == field.TypeBool: op = boolOps @@ -324,6 +326,12 @@ func hasField(v interface{}, name string) bool { return vr.FieldByName(name).IsValid() } +// hasImport reports if the package name exists in the predefined import packages. +func hasImport(name string) bool { + _, ok := importPkg[name] + return ok +} + // trimPackage trims the package name from the given identifier. func trimPackage(ident, pkg string) string { return strings.TrimPrefix(ident, pkg+".") diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 3e567bad2..131ed286d 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -626,7 +626,7 @@ func templateDialectSqlCreateTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlDecodeTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x5b\x6f\xdb\x36\x14\x7e\xb6\x7f\xc5\xa9\xe0\x04\xb6\x61\xcb\x69\x31\x0c\x58\xba\x0c\x28\x9a\x16\xf0\x36\x64\x45\xd2\xf4\xa5\x28\x06\x55\x3c\xb4\x39\x53\xa4\x4b\x52\xb9\x40\xd0\x7f\x1f\x78\x91\x45\xf9\xd6\x64\x43\xdf\x4c\x91\xe7\xf6\x9d\xef\x3b\xa4\xab\x6a\x36\xee\xbf\x95\xeb\x47\xc5\x16\x4b\x03\xaf\xce\x5e\xfe\x32\x5d\x2b\xd4\x28\x0c\xbc\xcf\x72\xfc\x2a\xe5\x0a\xe6\x22\x4f\xe1\x0d\xe7\xe0\x0e\x69\xb0\xfb\xea\x0e\x49\xda\xff\xb8\x64\x1a\xb4\x2c\x55\x8e\x90\x4b\x82\xc0\x34\x70\x96\xa3\xd0\x48\xa0\x14\x04\x15\x98\x25\xc2\x9b\x75\x96\x2f\x11\x5e\xa5\x67\xcd\x2e\x50\x59\x0a\xd2\x67\xc2\xed\xff\x39\x7f\xfb\xee\xea\xe6\x1d\x50\xc6\x11\xc2\x37\x25\xa5\x01\xc2\x14\xe6\x46\xaa\x47\x90\x14\x4c\x14\xcc\x28\xc4\xb4\x3f\x9e\xd5\x75\xbf\x5f\x55\x40\x90\x32\x81\x90\x10\x96\x71\xcc\xcd\x4c\x7f\xe3\x33\x82\x36\xa3\x99\x14\x98\x40\x5d\xdb\x53\x03\x85\x39\xb2\x3b\x54\x70\x7e\x01\x83\xf4\xba\x59\x59\x27\xb3\x19\xe8\x3c\x13\x9f\x32\x5e\xa2\xad\xd0\x94\x4a\x68\x97\x88\x79\x5c\xa3\x06\x2a\x95\x3b\x20\x98\x58\xc0\x9d\x3f\x45\x95\x2c\x40\x7f\xe3\xe9\xb5\xbc\xd7\x69\x9f\x96\x22\x87\xe1\xd8\x06\x4a\xaf\xb2\x02\xa1\xae\x47\x91\xd3\xe1\x08\x3e\x7f\x61\xc2\xa0\xa2\x59\x8e\x55\x0d\x55\xbf\xe7\xe3\xec\x7e\xef\x9d\x56\x15\x30\x0a\x42\x1a\x18\xa4\xf3\xcb\xf4\x56\xa3\xba\x74\x45\x12\xa8\x6b\x1b\xf3\xaa\xe4\x7c\x2e\xcc\xcf\x3f\x55\x15\x20\xd7\x36\x9a\x8b\x3c\xbf\x74\x5b\x1f\x1f\xd7\xe1\x13\x0a\x6b\x52\xd5\x13\x98\xcd\x60\x73\xc4\xe7\xd7\xef\xf5\xaa\x6a\x0a\x2a\x13\x0b\x84\xc1\xdf\x13\x18\x50\x8f\xcd\x7b\x86\x9c\x68\x7f\xc2\x25\x33\xa0\x1d\xb7\xad\x37\xba\xe5\xcb\x87\xeb\xf7\xea\xbe\x6b\xcd\x14\xee\x99\x59\x5a\x8f\x52\x21\x5b\x88\x3f\xf0\xd1\xbb\x9d\xcd\x80\xae\x9e\x06\x37\xf5\xa6\xd3\x95\xb5\xdd\x8f\x7d\x6f\x2f\xf8\x4d\x80\x7d\xd0\x1f\xc6\x3e\x86\x84\xae\x2c\x1e\x69\x00\xc2\xed\x04\x88\xe8\xca\x83\xd4\x6c\xc5\x1d\xa3\x4f\xef\x17\xfd\x5e\xb7\x62\x7c\x3b\x00\xf7\x1c\xc8\xd1\x17\xcb\xe1\x4c\x6b\xb6\x68\x58\xec\x17\x1e\xd6\x00\x9b\x59\x66\x06\xee\x51\x61\xc0\x1c\x49\x17\x49\x18\x66\xd4\x60\x8b\xfd\xc8\x3a\x35\xd2\xb9\x88\xb1\x05\xea\x08\xd2\x90\xbe\x23\xae\xba\x86\xad\x3e\xc4\x59\x0d\x43\x26\x69\x9a\x46\xc0\x8f\x00\x95\x92\xca\xe1\xcf\x28\x14\x13\x10\x16\x65\x8e\x22\x9c\x1f\x4d\xdc\xc2\xf9\xfd\x90\xe5\xab\x6c\x61\x5d\xa7\x6f\x25\x2f\x0b\xa1\x47\xaf\xa1\x80\x5f\x41\xf8\xfe\x85\xce\xd2\xc2\xa4\xef\xac\x57\x3a\x4c\x0a\xa6\x8b\xcc\xe4\x4b\x10\x65\xf1\x15\x95\x1d\x27\xb6\xc4\x00\xcb\x39\x9c\x10\x78\x71\x01\x27\x24\x99\xb8\xd8\x23\x0f\xaf\xc3\x9b\x51\xc8\x04\xd9\x95\xe1\x50\x2a\xff\x71\xae\x6f\x8c\xb2\x3c\x0d\xab\xdb\xdb\xf9\xe5\x28\x6a\x98\x13\x00\x3e\x18\xdb\xa6\x01\x24\x73\xf2\x90\xc0\x19\x24\x8e\x3d\x89\x33\x82\xe4\x1a\xf3\xa4\x03\x61\xa0\x1b\x18\x2c\xd6\x3c\x33\xfb\x67\x1b\xf5\x2e\xd2\x7d\xec\x70\x0b\xcf\x33\xbb\xe7\x0a\x9d\x80\x74\x7c\xf6\x55\x7f\x3e\xfb\x92\x0e\xc7\x1d\x6e\xda\xba\x2d\xfe\x2f\xe4\xca\x43\xb9\x0f\xcb\x52\xe0\xc3\x1a\x73\x83\xc4\x89\x15\x4e\x3e\x3a\xb9\xba\x64\x80\x59\x08\x9d\x7f\xe7\x2b\xe4\xd5\x29\xcd\x16\x7c\xb1\x99\x44\x81\xfa\xbe\xcd\xe9\x26\x8b\x4e\x2d\x81\x32\x9b\xc4\x5f\x9e\x7f\xe9\x4e\x2e\x76\x60\x72\x1d\x82\x7f\xc0\x5a\xfc\xe9\x0f\x43\x3f\x5e\x1c\x98\x82\xbb\xb5\x55\x95\x25\x7a\x5c\x88\x2b\xd6\x76\x25\x52\x03\x5c\x5c\xec\xd5\x43\xe4\x7f\x14\x3a\xb8\x0d\x53\x77\xa2\x1d\x1b\x69\x1d\xfa\xd3\x5d\xf2\xd3\x88\xfa\x74\x8b\xf8\x4f\xe3\xfe\x2e\xf6\xc9\x8d\x51\x65\x6e\x36\x07\xe2\xe9\xf7\x1f\x9a\xb2\xdd\x97\xde\x8e\x30\x3c\xb4\xfb\xe4\x61\xb1\x65\x50\xd7\xbb\x2a\x79\x1d\x09\xe4\x59\x1a\x41\xb2\xc0\xa9\x17\x4a\x3b\xdb\xeb\xba\x23\x19\xab\x1a\x9f\x60\x93\x57\xfa\x29\xe3\x8c\xb4\xf1\xb6\xf5\xd4\xb9\x26\xe0\x02\x04\xde\x0f\xfd\xb7\x20\xae\xc6\x6f\x6f\xfc\x3d\xd3\x8e\xd9\xb6\x26\x7b\x8d\xa0\x77\x40\xed\x2e\x77\x04\x10\x00\x12\x8c\xf7\xdd\x43\xac\xb9\xb0\x8e\xbf\xdc\x42\x2b\xad\x07\x47\x52\xe6\x05\x7e\x93\xcb\x35\xa6\x73\xf2\x00\xd3\xcd\x16\x8d\xb7\x3c\x87\xdb\x4d\x85\x26\xde\xbe\xc6\x3c\xb6\x74\x87\x1d\xfb\xd3\x88\x7a\xfe\x32\x0e\xa2\xf5\x76\x3b\xbb\xc1\xd6\x8b\xa9\xad\xaa\x51\x8d\x93\xc4\xef\x37\x7f\x5d\x79\x0c\x9e\x40\xb2\x9d\xf7\x40\x4c\xb4\xe7\x0e\xe2\x4e\x67\x1b\x82\x45\xf1\xdc\x15\xd7\xe5\x99\xbd\x02\x05\xe3\x70\x7a\xea\x66\xcb\xd8\x73\x12\x7e\x83\x33\x9f\x02\xa3\xf6\x96\xb6\xc9\xff\xa3\xa5\x48\x6f\x45\x91\x29\xbd\xcc\x78\x38\x39\x81\x53\x4f\x2f\xb3\x61\x56\x00\x6b\xf4\xda\x19\x06\xf7\x47\x2e\x96\xe0\x70\x5f\x09\xe7\x70\x72\x97\x4c\xac\x9f\xcd\xc5\x12\xb0\x6e\xc5\xec\x3a\x2a\x4a\xce\x1d\x1c\xbe\xa9\x1b\x38\xa7\xcf\x69\xc3\xc6\xc9\x8f\x6f\x42\xa0\xcb\x32\xd3\x1f\x14\x52\xf6\x10\x05\x4f\xf4\x37\x9e\x34\xa2\x3a\x32\x13\x5a\xc6\x5d\x31\xce\xb3\xaf\x1c\xa3\x69\xb7\xb7\x23\x47\xa6\xc4\xf8\xb0\x49\x97\xa0\x5e\x0a\x89\x4b\x27\xe9\x4c\x82\x78\xba\xfe\x7f\x6f\x07\x5e\x34\x07\xc8\xdb\x20\x72\x24\x6a\xfb\x4c\x8f\xe0\x1a\x6f\x14\xec\xdc\x6d\x8f\xb0\x86\x6b\x7e\x1d\xbf\xba\x8f\x0f\xb1\x22\x13\x8f\xcd\xff\xcf\xd6\x62\x36\x86\x37\x84\x30\xc3\xa4\x68\xd8\xee\xff\xf3\xd8\x77\xf6\x02\x05\xaa\xcc\x12\xaa\x90\x04\xb9\xfb\xbe\x94\x9c\xd8\x7b\xd6\xee\x77\xfe\x0e\xb9\xbf\xc0\x07\x52\x70\xe6\x7e\x8c\xea\x76\x8e\x76\xfe\xd9\xec\x79\x91\x1c\x7c\x10\x74\xef\x0a\x8f\xe3\x21\x0c\x3b\xc4\xda\x82\x2e\xfc\xfa\x37\x00\x00\xff\xff\x25\x3c\x48\x6c\x7b\x10\x00\x00") +var _templateDialectSqlDecodeTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\xdb\x6e\x1b\x37\x10\x7d\x96\xbe\x62\xb2\x90\x0d\x49\x90\x28\x27\x28\x0a\xd4\xa9\x0b\x04\x71\x02\xa8\x2d\xdc\xc0\x8e\xf3\x12\x04\xc5\x66\x39\x94\x58\x71\x49\x85\xa4\x7c\xc1\x62\xff\xbd\xe0\x65\x25\xae\x6e\xb1\x5b\xe4\x4d\xdc\xe1\x0c\x67\xce\x9c\x33\xa4\xaa\x6a\x32\xec\xbe\x55\xcb\x47\xcd\x67\x73\x0b\xaf\xce\x5e\xfe\x32\x5e\x6a\x34\x28\x2d\xbc\xcf\x0b\xfc\xaa\xd4\x02\xa6\xb2\x20\xf0\x46\x08\xf0\x9b\x0c\x38\xbb\xbe\x43\x4a\xba\x1f\xe7\xdc\x80\x51\x2b\x5d\x20\x14\x8a\x22\x70\x03\x82\x17\x28\x0d\x52\x58\x49\x8a\x1a\xec\x1c\xe1\xcd\x32\x2f\xe6\x08\xaf\xc8\x59\x63\x05\xa6\x56\x92\x76\xb9\xf4\xf6\x3f\xa7\x6f\xdf\x5d\xdd\xbc\x03\xc6\x05\x42\xfc\xa6\x95\xb2\x40\xb9\xc6\xc2\x2a\xfd\x08\x8a\x81\x4d\x0e\xb3\x1a\x91\x74\x87\x93\xba\xee\x76\xab\x0a\x28\x32\x2e\x11\x32\xca\x73\x81\x85\x9d\x98\x6f\x62\x42\xd1\x65\x34\x51\x12\x33\xa8\x6b\xb7\xab\xa7\xb1\x40\x7e\x87\x1a\xce\x2f\xa0\x47\xae\x9b\x95\x0b\x32\x99\x80\x29\x72\xf9\x29\x17\x2b\x74\x15\xda\x95\x96\xc6\x27\x62\x1f\x97\x68\x80\x29\xed\x37\x48\x2e\x67\x70\x17\x76\x31\xad\x4a\x30\xdf\x04\xb9\x56\xf7\x86\x74\xd9\x4a\x16\xd0\x1f\xba\x83\xc8\x55\x5e\x22\xd4\xf5\x20\x09\xda\x1f\xc0\xe7\x2f\x5c\x5a\xd4\x2c\x2f\xb0\xaa\xa1\xea\x76\xc2\x39\xbb\xdf\x3b\xa7\x55\x05\x9c\x81\x54\x16\x7a\x64\x7a\x49\x6e\x0d\xea\x4b\x5f\x24\x85\xba\x76\x67\x5e\xad\x84\x98\x4a\xfb\xf3\x4f\x55\x05\x28\x8c\x3b\xcd\x9f\x3c\xbd\xf4\xa6\x8f\x8f\xcb\xf8\x09\xa5\x73\xa9\xea\x11\x4c\x26\xb0\xde\x12\xf2\xeb\x76\x3a\x55\x35\x06\x9d\xcb\x19\x42\xef\xef\x11\xf4\x58\xc0\xe6\x3d\x47\x41\x4d\xd8\xe1\x93\xe9\xb1\x56\xd8\x4d\x34\xb6\x15\x2b\x1c\xd7\xed\xd4\x5d\xdf\x9a\x31\xdc\x73\x3b\x77\x11\x95\x46\x3e\x93\x7f\xe0\x63\x08\x3b\x99\x00\x5b\x3c\x0d\x6e\x16\x5c\xc7\x0b\xe7\xbb\x1f\xfb\xce\x5e\xf0\x9b\x03\xf6\x41\x7f\x18\xfb\x14\x12\xb6\x70\x78\x90\x08\x84\xb7\x44\x88\xd8\x22\x80\xd4\x98\xd2\x8e\xb1\xa7\xf7\x8b\x7d\xaf\x5b\x29\xbe\x2d\x80\x3b\x1e\xe4\xe4\x8b\xe3\x70\x6e\x0c\x9f\x35\x2c\x0e\x8b\x00\x6b\x84\xcd\xce\x73\x0b\xf7\xa8\x31\x62\x8e\xb4\x8d\x24\xf4\x73\x66\x71\x83\xfd\xc0\x05\xb5\xca\x87\x48\xb1\x05\xe6\x09\xd2\x90\xbe\x25\xae\xba\x86\xad\x3e\xa4\x59\xf5\x63\x26\x84\x90\x04\xf8\x01\xa0\xd6\x4a\x7b\xfc\x39\x83\x72\x04\xd2\xa1\x2c\x50\xc6\xfd\x83\x91\x5f\xf8\xb8\x1f\xf2\x62\x91\xcf\x5c\x68\xf2\x56\x89\x55\x29\xcd\xe0\x35\x94\xf0\x2b\xc8\xd0\xbf\xd8\x59\x56\x5a\xf2\xce\x45\x65\xfd\xac\xe4\xa6\xcc\x6d\x31\x07\xb9\x2a\xbf\xa2\x76\xe3\xc4\x95\x18\x61\x39\x87\x13\x0a\x2f\x2e\xe0\x84\x66\x23\x7f\xf6\x20\xc0\xeb\xf1\xe6\x0c\x72\x49\x77\x65\xd8\x57\x3a\x7c\x9c\x9a\x1b\xab\x1d\x4f\xe3\xea\xf6\x76\x7a\x39\x48\x1a\xe6\x05\x80\x0f\xd6\xb5\xa9\x07\xd9\x94\x3e\x64\x70\x06\x99\x67\x4f\xe6\x9d\x20\xbb\xc6\x22\x6b\x41\x18\xe9\x06\x16\xcb\xa5\xc8\xed\xfe\xd9\xc6\x42\x08\xb2\x8f\x1d\x7e\x11\x78\xe6\x6c\xbe\xd0\x11\x28\xcf\xe7\x50\xf5\xe7\xb3\x2f\xa4\x3f\x6c\x71\xd3\xd5\xed\xf0\x7f\xa1\x16\x01\xca\x7d\x58\xae\x24\x3e\x2c\xb1\xb0\x48\xbd\x58\xe1\xe4\xa3\x97\xab\x4f\x06\xb8\x83\xd0\xc7\xf7\xb1\x62\x5e\xad\xd2\x5c\xc1\x17\xeb\x49\x14\xa9\x1f\xda\x4c\xd6\x59\xb4\x6a\x89\x94\x59\x27\xfe\xf2\xfc\x4b\x7b\x72\xf1\x03\x93\xeb\x10\xfc\x3d\xbe\xc1\x9f\xfd\x30\xf4\xd3\xc5\x81\x29\xb8\x5b\x5b\x55\x39\xa2\xa7\x85\xf8\x62\x5d\x57\x12\x35\xc0\xc5\xc5\x5e\x3d\x24\xf1\x07\xb1\x83\xdb\x30\xb5\x27\xda\xb1\x91\xd6\xa2\x3f\xdb\x25\x3f\x4b\xa8\xcf\xb6\x88\xff\x34\xee\xef\x62\x9f\xdd\x58\xbd\x2a\xec\x7a\x43\x3a\xfd\xfe\x43\x53\xb6\xfb\xd2\xd9\x11\x46\x80\x76\x9f\x3c\x1c\xb6\x1c\xea\x7a\x57\x25\xaf\x13\x81\x3c\x4b\x23\x48\x67\x38\x0e\x42\xd9\xcc\xf6\xba\x6e\x49\xc6\xa9\x26\x24\xd8\xe4\x45\x3e\xe5\x82\xd3\xcd\x79\xdb\x7a\x6a\x5d\x13\x70\x01\x12\xef\xfb\xe1\x5b\x14\x57\x13\xb7\x33\xfc\x9e\x6b\xcb\x6d\x5b\x93\x9d\x46\xd0\x3b\xa0\xb6\x97\x3b\x02\x88\x00\x49\x2e\xba\xfe\x21\xd6\x5c\x58\xc7\x5f\x6e\xb1\x95\x2e\x82\x27\x29\x0f\x02\xbf\x29\xd4\x12\xc9\x94\x3e\xc0\x78\x6d\x62\xa9\x29\x70\x78\x63\xd4\x68\x53\xf3\x35\x16\xa9\xa7\xdf\xec\xd9\x4f\x12\xea\x85\xcb\x38\x8a\x36\xf8\xed\x58\xa3\x6f\x10\xd3\xa6\xaa\x46\x35\x5e\x12\xbf\xdf\xfc\x75\x15\x30\x78\x02\xc9\x76\xde\x03\x29\xd1\x9e\x3b\x88\x5b\x9d\x6d\x08\x96\x9c\xe7\xaf\xb8\x36\xcf\xdc\x15\x28\xb9\x80\xd3\x53\x3f\x5b\x86\x81\x93\xf0\x1b\x9c\x85\x14\x38\x73\xb7\xb4\x4b\xfe\x1f\xa3\x24\xb9\x95\x65\xae\xcd\x3c\x17\x71\xe7\x08\x4e\x03\xbd\xec\x9a\x59\x11\xac\xc1\x6b\xef\x18\xc3\x1f\xb9\x58\x62\xc0\x7d\x25\x9c\xc3\xc9\x5d\x36\x72\x71\xd6\x17\x4b\xc4\x7a\x23\x66\xdf\x51\xb9\x12\xc2\xc3\x11\x9a\xba\x86\x73\xfc\x9c\x36\xac\x83\xfc\xf8\x26\x24\x43\xb6\x1f\x5f\x8f\x2e\x5f\xe2\x9f\x4b\x37\xee\x1d\x86\x7a\x00\xfd\x79\x6e\x3e\x68\x64\xfc\x21\x49\x2e\x33\xdf\x44\xd6\x4c\xdc\x63\x43\x63\x43\xc9\x2b\x2e\x44\xfe\x55\x60\x32\x0e\xf7\xb6\xec\xc8\x18\x19\x1e\x76\x69\x33\x38\x68\x25\xf3\xe9\x64\xad\x51\x91\x8e\xdf\xff\x1f\xed\xc0\x93\xe7\x00\xbb\x1b\x44\x8e\x9c\xba\x79\xc7\x27\x70\x0d\xd7\x12\xf7\xe1\xb6\x67\x5c\x43\xc6\xb0\x4e\x9f\xe5\xc7\xa7\x5c\x99\xcb\xc7\xe6\x0f\xea\xc6\x63\x32\x84\x37\x94\x72\xcb\x95\x6c\xe4\x10\xfe\x14\xb9\x87\xf8\x0c\x25\xea\xdc\x31\xae\x54\x14\x85\xff\x3e\x57\x82\xba\x8b\xd8\xd9\x5b\xff\x97\xfc\x7f\xe4\x03\x29\x78\xf7\x30\x67\xcd\x66\xd0\xb6\xfe\xfa\xec\x79\xb2\x1c\x7c\x31\xb4\x2f\x93\x80\xe3\x21\x0c\x5b\xc4\xda\x82\x2e\xfe\xfa\x37\x00\x00\xff\xff\x88\x73\x60\xf1\x9c\x10\x00\x00") func templateDialectSqlDecodeTmplBytes() ([]byte, error) { return bindataRead( @@ -641,7 +641,7 @@ func templateDialectSqlDecodeTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/decode.tmpl", size: 4219, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/decode.tmpl", size: 4252, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -946,7 +946,7 @@ func templateHookTmpl() (*asset, error) { return a, nil } -var _templateImportTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x53\xc1\x6a\xdc\x30\x10\x3d\xaf\xbf\xe2\x61\xf6\x90\x04\x22\xa7\xb9\x35\x90\x43\x48\x13\x58\x28\x25\x90\xfc\x80\x56\x1a\xdb\x43\xbc\x92\x3b\x9a\x4d\x1b\x8c\xff\xbd\x58\x6b\x37\x59\xb6\xd0\x93\x9f\xf5\x66\xde\x8c\x66\x9e\x86\xa1\xba\x28\xee\x63\xff\x2e\xdc\xb4\x8a\xeb\xab\x2f\x5f\x2f\x7b\xa1\x44\x41\xf1\x68\x1d\x6d\x63\x7c\xc5\x26\x38\x83\xbb\xae\x43\x0e\x4a\x98\x78\x79\x23\x6f\x8a\x97\x96\x13\x52\xdc\x8b\x23\xb8\xe8\x09\x9c\xd0\xb1\xa3\x90\xc8\x63\x1f\x3c\x09\xb4\x25\xdc\xf5\xd6\xb5\x84\x6b\x73\xb5\xb0\xa8\xe3\x3e\xf8\x82\x43\xe6\xbf\x6f\xee\x1f\x7e\x3c\x3f\xa0\xe6\x8e\x30\x9f\x49\x8c\x0a\xcf\x42\x4e\xa3\xbc\x23\xd6\xd0\x4f\xc5\x54\x88\x4c\x71\x51\x8d\x63\x51\x0c\x03\x3c\xd5\x1c\x08\x25\xef\xfa\x28\x5a\x62\x1c\x8b\x03\xc4\x59\xb1\x2a\xeb\x9d\x96\xc5\xaa\x74\x31\x28\xfd\xce\x90\x44\xa2\xa4\x09\xed\xac\xb6\xd3\x37\xa9\x70\x68\xf2\x91\xf2\x8e\xca\x62\x35\x0c\x97\xa8\x2e\xc0\x4d\x88\x42\x68\x28\x90\x28\x87\x06\x31\xa0\x11\xdb\xb7\x48\x3d\x39\xae\xb9\x76\x50\xda\xf5\x9d\x55\x4a\xc8\x1d\xe5\x54\xae\x11\xa2\xe2\x8c\x7e\x62\x6d\xee\x63\xa8\xb9\x31\x4f\xd6\xbd\xda\x86\xb0\x5e\xd0\xf9\xd4\xe9\x6a\x55\x0e\xc3\x69\xd0\x38\x56\xbd\x90\x67\x67\x75\x6a\x27\x8b\xfe\x62\x6d\xb1\x36\x9b\x6f\xe6\xe5\xbd\x27\xf3\xf4\xda\x3c\x59\x6d\x0f\x22\x59\xc5\x60\x1c\x97\x60\x0a\xfe\xc0\x4c\x3f\x62\xc3\x54\xb8\xc6\xcd\x2d\xd6\xe6\x91\xa9\xf3\x69\xce\xfb\x10\xae\xff\x25\x7b\xa4\x7b\x2a\xbc\xfc\x7c\xc6\x65\xc3\xda\xee\xb7\xc6\xc5\x5d\x55\xcf\x2e\xe2\xe0\xf6\x5b\xab\x51\x2a\x0a\x79\x07\xff\x8b\xa9\x3c\xdb\x8e\x9c\xce\xab\x98\xaf\xfe\xac\x51\x0e\xd3\x39\xbe\xd8\xbc\xee\x9b\x5b\x98\x4d\x86\xe9\xd3\x54\x16\xf6\x74\x36\xc7\xf8\xef\x22\x17\x27\xa5\xca\x7a\xcf\xca\x31\xd8\xae\xc4\x7a\x0a\x3b\x9f\xfc\x36\xa7\x14\xd3\xf3\xc1\xdd\x47\x9a\xb6\x56\xe1\x6c\xc0\x96\x10\xdf\x48\x84\x3d\xf9\xc9\xd1\x51\xf2\x5b\x88\xb0\xde\xe3\x43\x13\x73\x99\x89\xe9\x0f\x7b\x4f\x26\x7b\xe8\xc4\xd4\xc7\xad\x8c\xe3\x30\x50\xf0\xe3\x58\xfc\x09\x00\x00\xff\xff\x98\xf7\x00\x1d\xc2\x03\x00\x00") +var _templateImportTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x53\xc1\x6a\xdc\x30\x10\x3d\xaf\xbf\xe2\x61\xf6\x90\x0d\x44\x4e\x73\x6b\x20\x87\x90\x26\xb0\x50\x4a\x20\xf9\x01\xad\x34\xb6\x87\xf5\x4a\xae\x34\x9b\x36\x18\xff\x7b\x91\x6c\x37\x59\xb6\xd0\x93\xc7\x7a\x33\xa3\x37\x4f\x6f\x86\xa1\xba\x2c\x1e\x7c\xff\x1e\xb8\x69\x05\x37\xd7\x5f\xbe\x5e\xf5\x81\x22\x39\xc1\x93\x36\xb4\xf3\x7e\x8f\xad\x33\x0a\xf7\x5d\x87\x9c\x14\x91\xf0\xf0\x46\x56\x15\xaf\x2d\x47\x44\x7f\x0c\x86\x60\xbc\x25\x70\x44\xc7\x86\x5c\x24\x8b\xa3\xb3\x14\x20\x2d\xe1\xbe\xd7\xa6\x25\xdc\xa8\xeb\x05\x45\xed\x8f\xce\x16\xec\x32\xfe\x7d\xfb\xf0\xf8\xe3\xe5\x11\x35\x77\x84\xf9\x2c\x78\x2f\xb0\x1c\xc8\x88\x0f\xef\xf0\x35\xe4\xd3\x65\x12\x88\x54\x71\x59\x8d\x63\x51\x0c\x03\x2c\xd5\xec\x08\x25\x1f\x7a\x1f\xa4\xc4\x38\x16\x53\x88\x8b\x62\x55\xd6\x07\x29\x8b\x55\x69\xbc\x13\xfa\x9d\x43\x0a\xc1\x87\x98\xa2\x83\x96\x36\x7d\xa3\x04\x76\x4d\x3e\x12\x3e\x50\x59\xac\x86\xe1\x0a\xd5\x25\xb8\x71\x3e\x10\x1a\x72\x14\x84\x5d\x03\xef\xd0\x04\xdd\xb7\x88\x3d\x19\xae\xb9\x36\x10\x3a\xf4\x9d\x16\x8a\xc8\x8c\x72\x29\xd7\x70\x5e\x70\x41\x3f\xb1\x56\x0f\xde\xd5\xdc\xa8\x67\x6d\xf6\xba\x21\xac\x97\x68\x93\x98\xae\x56\xe5\x30\x9c\x27\x8d\x63\xd5\x07\xb2\x6c\xb4\x24\x3a\xb9\xe9\x2f\x96\x16\x6b\xb5\xfd\xa6\x5e\xdf\x7b\x52\xcf\xfb\xe6\x59\x4b\x3b\x35\xc9\x5d\x14\xc6\x71\x49\x26\x67\x27\x24\xfd\x04\xed\xd2\xc5\x35\x6e\xef\xb0\x56\x4f\x4c\x9d\x8d\x73\x5d\x82\xd7\xfd\xbe\xc9\x50\xfd\xaf\xce\xf3\x3c\xda\xd9\x29\xf1\x22\x4f\xd6\xea\xb8\x9d\x45\xde\xe9\x48\x13\xb4\xd9\xcc\x33\xcd\x53\xa5\xb3\x89\xd2\x39\xa7\xe5\xe7\x73\x5c\x36\x2c\xed\x71\xa7\x8c\x3f\x54\xf5\x6c\x40\x76\xe6\xb8\xd3\xe2\x43\x45\x2e\x3f\xdf\xff\x72\x2a\xcb\xba\x23\x23\xf3\x2b\xce\xaa\xbd\x88\x0f\x93\xb0\xa7\x9a\xcc\x4e\xb9\xbd\x83\x9a\xe6\x89\x9f\x04\x5d\xd0\x73\x59\x4f\xe3\xbf\x1e\x58\x4c\x18\x2b\x6d\x2d\x0b\x7b\xa7\xbb\x12\xeb\x94\xb6\x49\x56\x9d\x4b\x8a\xb4\x79\xb8\xff\x28\x93\x56\x0b\x8c\x76\xd8\x11\xfc\x1b\x85\xc0\x96\x6c\x5a\x06\x1f\xf2\x1a\x79\x68\x6b\xf1\xd1\x13\xf3\x35\x09\xe9\x27\xcb\x44\x95\xed\x77\xb6\x0f\xa7\x54\xc6\x71\x18\xc8\xd9\x71\x2c\xfe\x04\x00\x00\xff\xff\xd2\x61\x7f\x2f\xfd\x03\x00\x00") func templateImportTmplBytes() ([]byte, error) { return bindataRead( @@ -961,7 +961,7 @@ func templateImportTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/import.tmpl", size: 962, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/import.tmpl", size: 1021, 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\xdf\x6f\xdb\x36\x10\x7e\xb6\xfe\x8a\x83\xa0\x62\x76\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\xa5\x81\xa0\xff\x7d\x38\x52\xbf\xec\x38\x89\xb3\x06\x43\xf3\xe4\x90\xc7\xfb\xf1\xdd\xf7\x1d\xc5\xa6\x49\x5f\x46\x6f\x75\x75\x6b\xe4\xaa\x70\xf0\xe6\xf5\x8f\x3f\x1d\x55\x06\x2d\x2a\x07\xef\x78\x86\x57\x5a\x5f\xc3\x52\x65\x0c\x4e\xca\x12\xbc\x91\x05\xda\x37\x35\x0a\x16\x7d\x2c\xa4\x05\xab\x37\x26\x43\xc8\xb4\x40\x90\x16\x4a\x99\xa1\xb2\x28\x60\xa3\x04\x1a\x70\x05\xc2\x49\xc5\xb3\x02\xe1\x0d\x7b\xdd\xef\x42\xae\x37\x4a\x44\x52\xf9\xfd\xdf\x97\x6f\xcf\xce\x2f\xcf\x20\x97\x25\x42\xb7\x66\xb4\x76\x20\xa4\xc1\xcc\x69\x73\x0b\x3a\x07\x37\x09\xe6\x0c\x22\x8b\x5e\xa6\x6d\x1b\x45\x4d\x03\x02\x73\xa9\x10\xe2\x9b\x02\x0d\xc6\x10\x56\x8f\xe0\x46\xba\x02\xf0\xab\x43\x25\x20\x81\xf8\x03\xcf\xae\xf9\x0a\x63\x48\x58\xf7\x13\x8e\xda\x36\x9a\x35\x0d\x38\x5c\x57\x25\x77\x08\x71\x81\x5c\xa0\x89\x81\x91\x97\xa6\x01\x3a\xdb\x45\x19\x8d\xe4\xba\xd2\xc6\xc5\x90\xf8\xad\x34\x85\xe5\x29\x25\xef\xd0\x58\xa8\xd1\x38\x99\xa1\x85\x2b\x4e\x28\x68\x5f\x8e\x34\x20\x05\x2a\x27\x73\x89\x86\x45\xf9\x46\x65\xb0\x3c\x9d\x4b\x01\x4d\x03\x09\x5b\x9e\xb2\x8f\xb7\x15\x42\xdb\x2e\xa0\x32\x28\x64\xc6\x1d\x32\xbf\x75\xce\xd7\xb4\x0e\x4d\x34\x33\xe8\x36\x46\xdd\x63\x30\x8f\x66\x33\xaa\x39\x71\xeb\xaa\x84\x9f\x8f\xa1\x32\x52\xb9\x1c\x62\x21\x79\x89\x99\x4b\x5f\xd8\x74\x38\x99\x4a\x41\x28\x5c\x3a\x6d\x08\x05\x02\xc1\x1f\xfe\x3a\x94\x18\xdc\x24\x01\xa0\x45\x14\x00\x30\x5c\xad\x10\x12\x5d\x91\x7f\x5d\x59\x9f\x39\x74\x10\x26\xdc\xac\x68\x3d\x26\xdf\x6d\xdb\x34\x20\x73\xb2\x65\x7f\x71\x23\xb9\x90\x59\x58\xf4\x66\xde\xca\x76\x66\x1d\xc2\xde\x87\x07\x66\x92\xfc\xf2\xf4\x85\x8d\xbd\x97\xae\xcc\x68\x96\xa6\x30\x58\xb6\x2d\xf0\xaa\x2a\x25\x5a\xcf\x19\x5a\x1f\x4d\x47\xa0\xba\x26\x84\x2e\x61\x29\x58\x34\xf3\xc7\x27\x7e\xe6\x7d\x6a\x04\xf5\xbe\xd4\x19\x63\x43\xae\x4f\xe8\xd9\xe3\x4d\x9b\xed\x61\xea\x89\x59\xc5\x21\x9d\xf8\xa2\xf2\xf5\x43\xdc\x35\x6b\xda\x37\xdf\x1c\xef\xe1\xe0\xb6\xa7\xba\xb2\x77\x5a\xbf\xbf\xf9\xac\xdb\xa4\x3d\xca\x2b\x44\x5b\x44\xb3\x5d\x5d\x74\xb4\xc8\x29\x7c\xc2\xde\x11\xc2\xb6\xeb\x68\xfa\x12\x7e\xbb\xbc\x38\x87\x8c\x2b\xa5\x1d\x5c\xd1\x98\x58\x57\xdc\xd0\x78\xb0\x52\xad\x20\x3e\x8e\x81\x2b\x01\x67\x6a\xb3\x86\x82\x5b\xe0\xe0\x08\xd5\xa0\x68\x11\x80\xa1\xde\xf9\xc6\x81\x22\xdc\xbc\xec\x7d\xd1\x05\xb7\x1f\x28\x2a\xf9\x9e\x6b\x03\x49\xce\x96\xd6\x07\xf4\xbf\xc8\xe9\x62\xe0\x56\x88\xcc\xaf\x4a\xf4\xf4\x35\x30\xa7\x63\x49\xce\xde\x73\xfb\xab\xa6\x5e\x2e\x60\x9e\xe4\xec\x17\x6e\x65\xe6\x5b\x1b\xd7\x71\x7f\xfc\x88\x28\x41\x89\x86\x98\x53\x67\x6d\x1b\x41\xf7\x37\x95\x41\x1d\xf7\xba\x1a\x69\x9d\xe4\xec\xd2\x99\x4d\xe6\x3c\x48\x61\xff\x1e\x3e\xe3\x97\x0d\x2f\xa5\xbb\x85\xac\xc0\xec\xfa\x2e\x97\x9b\x06\xbe\x6c\x34\x35\x2b\x1f\xf8\x16\xc8\x0d\x4b\xf7\x83\xed\xc6\x4d\xc6\x4b\x70\x7a\x1a\xe0\xec\x0f\x16\xcd\x1e\xa3\x7f\x92\x1f\xc4\xed\x1e\x97\x29\x86\x3d\xa3\x6a\x5f\x70\xf0\xb5\x85\xe8\x14\xaf\x11\xb7\xa3\x61\x30\xd4\xd9\x1d\x93\x9e\x81\xc1\xf5\xe3\x8a\x7a\x44\x52\x1e\xfc\x98\x08\xdb\x0b\xe8\x70\x05\xe5\xdd\xd9\x5d\x01\x3d\xa8\xa0\x1d\x09\x91\x86\x66\x1d\xab\xba\xb2\x0e\x16\x14\xcd\x02\x3b\x8c\xdf\xbc\x5f\xf5\xc5\x0e\x49\xb1\x8b\xca\x8e\xe4\x23\xcb\x63\xe2\x15\x2a\x61\xc3\xbf\xf3\x8c\x97\xe5\x8e\x7d\x92\x0f\x52\x99\x4c\xe4\xad\x91\xef\xcf\xee\x8e\xfb\xfa\x90\x69\x5f\x3f\x3a\xec\x77\xb5\xb1\x35\xf3\x7d\x7b\x88\x3f\x41\x43\x44\x25\x32\xa6\x01\x32\xc4\xee\x05\xdf\x05\xf6\xe6\xc7\xe0\x8c\x5c\xf7\x97\x7d\x58\x1b\x2f\xff\xad\x84\xbe\xe1\x5a\xb9\x5f\x8a\xfb\xef\x19\x99\xfb\x81\xe5\x7d\xca\x72\x07\xac\x43\xef\x1f\x17\xb4\x36\xac\x3d\x28\xd4\x5e\xa7\xdb\x2e\x89\x8a\x35\x41\xba\xe6\xd7\x38\xff\xf4\x59\x2a\x87\x26\xe7\x19\x36\xed\x2b\x28\x51\x4d\x86\xc2\x82\x28\x3b\xcb\xb5\x01\x49\x07\x02\x2b\xea\x30\x04\x66\xf5\x27\xf9\x19\x8e\x61\xb4\xfe\x24\x3f\xd3\xc6\x70\x7b\x0c\x2c\x88\xc7\x4f\x0d\x2c\x2d\xf6\x33\x75\xbe\x03\xc7\x62\xdf\x44\x79\x70\xa0\xec\x06\xca\xa6\x91\xfa\xc9\xf1\xad\x57\xf1\x38\x37\x9e\xf7\x56\xf6\x5c\x79\x9e\x8b\x79\xa2\xde\xbd\x23\xe5\x9f\x57\x90\x04\x15\xb1\x33\xb1\x42\x7b\x8f\x16\xe3\xf7\x9c\x92\xc1\x3b\xb7\xd5\x03\x2a\x79\xcf\x2d\xb9\x7c\x48\x1e\x38\x90\x12\xc5\x0a\xf7\xa9\xe3\xf9\x3f\xa5\x28\x27\x2a\xe5\xe9\x6d\xa1\x1c\xd3\x82\x3f\x53\x57\x42\x89\x63\xc8\x17\xf6\x6f\xe9\x8a\x78\x28\xfd\x79\xb1\x0d\x28\x70\x58\xc9\x1a\x15\x64\x5a\x09\xe9\xa4\x56\x16\xe6\xda\x15\x68\x46\x47\x76\xb1\xaf\x0d\xb4\x6d\x81\x31\xb6\x8d\x35\x86\xc9\xdb\x05\xfa\x1e\x7b\x75\x13\x30\x7d\xbe\xcf\xdb\x34\x85\x13\x25\x60\x65\xf4\xa6\xa2\xb7\xad\x75\xf4\x14\x1d\xe1\x1b\x3f\x50\x4f\xce\x4f\x41\x57\x68\xb8\xd3\x06\xae\xd0\xdd\x20\xfa\x1e\xad\xbb\xe7\xde\x89\x12\xf3\xc9\xb9\x3b\xe0\x1e\x02\xeb\x13\x5e\x80\x8f\x00\xc6\xd5\x61\x2f\x40\x36\x79\x01\xa6\x29\x5c\x98\x43\xa0\xb8\xf8\xf3\x41\x24\x2e\xcc\x77\x04\x84\x36\xff\x05\x87\x73\xed\xb6\x04\x4a\x17\xd8\x50\x72\xa7\xcd\xa0\xbd\x31\xc5\x50\xfc\xb9\x76\xf3\xea\x9e\xc4\xff\x9f\x8a\x95\x76\x4f\x2e\x79\x54\xc4\xbf\x01\x00\x00\xff\xff\xf7\x8d\xd8\x59\x32\x12\x00\x00") +var _templateWhereTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x57\x4d\x6f\xe3\x36\x10\x3d\x5b\xbf\x62\x20\x28\xa8\xbd\xe8\x52\xdb\xbd\xb5\x40\x0e\xe9\x26\xdb\x75\x51\x24\xdb\x26\x68\x0f\x41\x0e\x8c\x34\xb2\x88\xc8\xa4\x96\xa4\x9d\x0d\x04\xfd\xf7\x62\x48\xea\xc3\x8e\x93\x38\x5d\xa3\xd8\x9c\x62\x72\x38\x1f\x6f\xde\x1b\x8a\x4d\x93\xbe\x89\x3e\xa8\xfa\x41\x8b\x45\x69\xe1\xfd\xbb\x9f\x7e\x7e\x5b\x6b\x34\x28\x2d\x7c\xe4\x19\xde\x2a\x75\x07\x73\x99\x31\x38\xa9\x2a\x70\x46\x06\x68\x5f\xaf\x31\x67\xd1\x55\x29\x0c\x18\xb5\xd2\x19\x42\xa6\x72\x04\x61\xa0\x12\x19\x4a\x83\x39\xac\x64\x8e\x1a\x6c\x89\x70\x52\xf3\xac\x44\x78\xcf\xde\x75\xbb\x50\xa8\x95\xcc\x23\x21\xdd\xfe\x1f\xf3\x0f\x67\xe7\x97\x67\x50\x88\x0a\x21\xac\x69\xa5\x2c\xe4\x42\x63\x66\x95\x7e\x00\x55\x80\x1d\x05\xb3\x1a\x91\x45\x6f\xd2\xb6\x8d\xa2\xa6\x81\x1c\x0b\x21\x11\xe2\xfb\x12\x35\xc6\xe0\x57\xdf\xc2\xbd\xb0\x25\xe0\x57\x8b\x32\x87\x04\xe2\xcf\x3c\xbb\xe3\x0b\x8c\x21\x61\xe1\x5f\x78\xdb\xb6\xd1\xa4\x69\xc0\xe2\xb2\xae\xb8\x45\x88\x4b\xe4\x39\xea\x18\x18\x79\x69\x1a\xa0\xb3\x21\xca\x60\x24\x96\xb5\xd2\x36\x86\xc4\x6d\xa5\x29\xcc\x4f\x29\x79\x8b\xda\xc0\x1a\xb5\x15\x19\x1a\xb8\xe5\x84\x82\x72\xe5\x08\x0d\x22\x47\x69\x45\x21\x50\xb3\xa8\x58\xc9\x0c\xe6\xa7\x53\x91\x43\xd3\x40\xc2\xe6\xa7\xec\xea\xa1\x46\x68\xdb\x19\xd4\x1a\x73\x91\x71\x8b\xcc\x6d\x9d\xf3\x25\xad\x43\x13\x4d\x34\xda\x95\x96\x4f\x18\x4c\xa3\xc9\x84\x6a\x4e\xec\xb2\xae\xe0\x97\x63\xa8\xb5\x90\xb6\x80\x38\x17\xbc\xc2\xcc\xa6\x47\x26\xed\x4f\xa6\x22\x27\x14\x2e\xad\xd2\x84\x02\x81\xe0\x0e\x7f\xed\x4b\xf4\x6e\x12\x0f\xd0\x2c\xf2\x00\x68\x2e\x17\x08\x89\xaa\xc9\xbf\xaa\x8d\xcb\x1c\x02\x84\x09\xd7\x0b\x5a\x8f\xc9\x77\xdb\x36\x0d\x88\x82\x6c\xd9\xdf\x5c\x0b\x9e\x8b\xcc\x2f\x3a\x33\x67\x65\x82\x59\x40\xd8\xf9\x70\xc0\x8c\x92\x9f\x9f\x1e\x99\xd8\x79\x09\x65\x46\x93\x34\x85\xde\xb2\x6d\x81\xd7\x75\x25\xd0\x38\xce\xd0\xfa\x60\x3a\x00\x15\x9a\xe0\xbb\x84\x55\xce\xa2\x89\x3b\x3e\xf2\x33\xed\x52\x23\xa8\x77\xa5\xce\x18\xeb\x73\x7d\x45\xcf\x5e\x6e\xda\x64\x07\x53\x4f\xf4\x22\xf6\xe9\xc4\x17\xb5\xab\x1f\xe2\xd0\xac\x71\xdf\x5c\x73\x9c\x87\xbd\xdb\x9e\xaa\xda\x3c\x6a\xfd\xee\xe6\xb3\xb0\x49\x7b\x94\x97\x8f\x36\x8b\x26\xdb\xba\x08\xb4\x28\x28\x7c\xc2\x3e\x12\xc2\x26\x74\x34\x7d\x03\xbf\x5f\x5e\x9c\x43\xc6\xa5\x54\x16\x6e\x69\x4c\x2c\x6b\xae\x69\x3c\x18\x21\x17\x10\x1f\xc7\xc0\x65\x0e\x67\x72\xb5\x84\x92\x1b\xe0\x60\x09\x55\xaf\xe8\xdc\x03\x43\xbd\x73\x8d\x03\x49\xb8\x39\xd9\xbb\xa2\x4b\x6e\x3e\x53\x54\xf2\x3d\x55\x1a\x92\x82\xcd\x8d\x0b\xe8\xfe\x23\xa7\xb3\x9e\x5b\x3e\x32\xbf\xad\xd0\xd1\x57\xc3\x94\x8e\x25\x05\xfb\xc4\xcd\x6f\x8a\x7a\x39\xa3\x5f\x1f\x94\x24\x09\x63\x7e\xa5\x7e\xe5\xc6\xf5\x3e\x72\x18\x88\xc2\x65\xea\x83\x8e\xbd\xb5\x6d\x04\xe1\x6f\xac\x83\x75\xdc\x09\x6b\xe0\x75\x52\xb0\x4b\xab\x57\x99\x75\x28\xf9\xfd\x27\x08\x8d\x5f\x56\xbc\x12\xf6\x01\xb2\x12\xb3\xbb\xc7\x64\x6e\x1a\xf8\xb2\x52\xd4\xad\xa2\x27\x9c\x67\x37\xcc\xed\x0f\x26\xcc\x9b\x8c\x57\x60\xd5\x38\xc0\xd9\x9f\x2c\x9a\xbc\xc4\xff\xa4\xd8\x8b\xdc\x1d\x2e\x63\x10\x3b\x4a\xad\x5d\xc1\xde\x97\x03\xd2\x6d\x06\x54\x60\xeb\xcf\x4d\xae\x30\x19\xd6\xd9\x23\x93\x8e\x82\xde\xf5\xcb\x92\x7a\x41\x53\x0e\xfc\x98\x18\xdb\x29\x68\x7f\x09\x15\xe1\xec\xb6\x82\x9e\x95\xd0\x96\x86\x48\x44\x93\xc0\xaa\x50\xd6\xde\x8a\xa2\x61\x60\xfa\xf9\x5b\x74\xab\xae\xd8\x3e\x29\x76\x51\x9b\x81\x7c\x64\x79\x4c\xbc\x42\x99\x1b\xff\x73\x9a\xf1\xaa\xda\xb2\x4f\x8a\x5e\x2b\xa3\x91\xbc\x31\xf3\xdd\xd9\xed\x79\xbf\xde\x67\xdc\xaf\x5f\x9c\xf6\xdb\xda\xd8\x18\xfa\xae\x3d\xc4\x1f\xaf\x21\xa2\x12\x19\xd3\x04\xe9\x63\x77\x8a\x0f\x81\x9d\xf9\x31\x58\x2d\x96\xdd\x6d\xef\xd7\x86\xdb\x7f\x23\xa1\x6f\xb8\x57\x9e\x96\xe2\xee\x8b\x46\x14\x6e\x62\x39\x9f\xa2\xda\x02\x6b\xdf\x0b\xc8\x7a\xad\xf5\x6b\xcf\x0a\xb5\xd3\xe9\xa6\x4b\xa2\xe2\x9a\x20\x5d\xf2\x3b\x9c\x5e\xdf\x08\x69\x51\x17\x3c\xc3\xa6\xfd\x11\x2a\x94\xa3\xa1\x30\x23\xca\x4e\x0a\xa5\x41\xd0\x01\xcf\x8a\x35\x34\x1b\x32\x1d\x0b\x6f\x43\xf5\xd3\x4e\x52\x47\xe6\x5a\xdc\x78\x19\xce\x7a\xe5\xac\xaf\xc5\x0d\xb8\x51\xb1\xa9\x97\xca\xe0\x0e\x9b\x90\xd0\xb5\xb8\xd9\x50\x96\x37\xec\x2f\xac\x9e\x77\xf1\xf0\x75\xe3\x1c\x86\x29\x3e\xdd\x6a\xc0\x6c\xd7\x0c\x7b\x76\x84\x6d\x07\xca\xc6\x91\xba\x84\xbe\xf5\xf6\x1f\x26\xd5\x61\x3f\x04\x1c\x3b\x0f\xf3\x2d\x30\x9a\x17\x3b\x87\x98\xd7\x2c\x3b\xcb\x17\x68\x9e\x50\x7e\xfc\x89\x53\x22\xf8\xe8\x6e\x7c\x46\x93\x9f\xb8\x21\x97\xcf\x89\x11\x7b\x09\x60\xbe\xc0\x5d\x5a\x3c\xfc\x97\x1b\xe5\x44\xa5\xbc\xbe\x25\x94\x63\x5a\xf2\x03\x75\xc4\x97\x38\x84\x3c\x32\xff\x08\x5b\xc6\x7d\xe9\x87\xc5\xd6\xa3\xc0\x61\x21\xd6\x28\x21\x53\x32\x17\x56\x28\x69\x60\xaa\x6c\x89\x7a\x70\x64\x66\xbb\xda\x40\xdb\x06\x18\x63\x9b\x58\xa3\x9f\xf3\x21\xd0\xf7\xd8\xab\x7b\x8f\xe9\xe1\xbe\xa6\xd3\x14\x4e\x64\x0e\x0b\xad\x56\x35\x3d\xa5\x8d\xa5\x97\xef\x00\xdf\xf0\x3d\x7c\x72\x7e\x0a\xaa\x46\xcd\xad\xd2\x70\x8b\xf6\x1e\xd1\xf5\x68\x19\x5e\x97\x27\x32\x9f\x8e\xce\x3d\x02\x77\x1f\x58\x5f\xf1\xe0\x7c\x01\x30\x2e\xf7\x7b\x70\xb2\xd1\x83\x33\x4d\xe1\x42\xef\x03\xc5\xc5\x5f\xcf\x22\x71\xa1\xbf\x23\x20\x94\xfe\x2f\x38\x9c\x2b\xbb\x21\x50\xba\xbc\xfa\x92\x83\x36\xbd\xf6\x86\x14\x7d\xf1\xe7\xca\x4e\xeb\x27\x12\xff\x7f\x2a\x96\xca\xbe\xba\xe4\x41\x11\xff\x06\x00\x00\xff\xff\x71\x4e\xe9\x1f\xa1\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: 4658, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/where.tmpl", size: 4769, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/storage.go b/entc/gen/storage.go index beecc12d1..80a66e766 100644 --- a/entc/gen/storage.go +++ b/entc/gen/storage.go @@ -58,10 +58,10 @@ var drivers = []*Storage{ }, SchemaMode: Unique | Indexes | Cascade | Migrate, Ops: func(f *Field) []Op { - if !f.IsString() { - return nil + if f.IsString() && f.ConvertedToBasic() { + return []Op{EqualFold, ContainsFold} } - return []Op{EqualFold, ContainsFold} + return nil }, OpCode: opCodes(sqlCode[:]), }, diff --git a/entc/gen/template/dialect/sql/decode.tmpl b/entc/gen/template/dialect/sql/decode.tmpl index 96a863283..ef44d288e 100644 --- a/entc/gen/template/dialect/sql/decode.tmpl +++ b/entc/gen/template/dialect/sql/decode.tmpl @@ -93,7 +93,7 @@ func ({{ $receiver }} *{{ $.Name }}) assignValues(values ...interface{}) error { {{- $nulltype := $f.NullType -}} if value, ok := values[{{ $i }}].(*{{ $nulltype }}); !ok { return fmt.Errorf("unexpected type %T for field {{ $f.Name }}", values[{{ $i }}]) - {{- if hasPrefix $nulltype "sql" }} + {{- if and (not $f.Type.ValueScanner) (hasPrefix $nulltype "sql") }} } else if value.Valid { {{- if $f.Nillable }} {{ $ret }}.{{ $field }} = new({{ $f.Type }}) diff --git a/entc/gen/template/import.tmpl b/entc/gen/template/import.tmpl index 776fd2bef..23fd55bff 100644 --- a/entc/gen/template/import.tmpl +++ b/entc/gen/template/import.tmpl @@ -19,8 +19,9 @@ import ( "{{ . }}" {{- end }} {{- range $f := $.Fields }} - {{- with $f.Type.PkgPath }} - "{{ . }}" + {{- $pkg := $f.Type.PkgPath }} + {{- if and $pkg (not (hasImport (base $pkg ))) }} + "{{ $pkg }}" {{- end }} {{- end }} {{- end }} diff --git a/entc/gen/template/where.tmpl b/entc/gen/template/where.tmpl index 7c21bd07e..d6b88e363 100644 --- a/entc/gen/template/where.tmpl +++ b/entc/gen/template/where.tmpl @@ -37,7 +37,7 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { {{ range $f := $.Fields }} {{/* JSON cannot be compared using "=" and Enum has a type defined with the field name */}} {{ $hasP := not (or $f.IsJSON $f.IsEnum) }} - {{ $comparable := or (not $f.HasGoType) ($f.BasicType "v") }} + {{ $comparable := or (not $f.HasGoType) $f.ConvertedToBasic }} {{- if and $hasP $comparable }} {{ $arg := "v" }} {{ $func := $f.StructField }} @@ -71,7 +71,11 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { {{- if $op.Variadic }} v := make([]interface{}, len({{ $arg }})) for i := range v { - v[i] = {{ $arg }}[i] + {{- with $f.BasicType (printf "%s[i]" $arg) }} + v[i] = {{ . }} + {{- else }} + v[i] = {{ $arg }}[i] + {{- end }} } {{- $arg = "v" }} {{- else if and (not $op.Niladic) $f.HasGoType }} @@ -88,7 +92,7 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { {{ end }} {{ end }} -{{ range $_, $e := $.Edges }} +{{ range $e := $.Edges }} {{ $func := print "Has" $e.StructField }} // {{ $func }} applies the HasEdge predicate on the {{ quote $e.Name }} edge. func {{ $func }}() predicate.{{ $.Name }} { diff --git a/entc/gen/type.go b/entc/gen/type.go index 34be84d4d..044ed6b07 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -674,6 +674,9 @@ func (f Field) Sensitive() bool { return f.def != nil && f.def.Sensitive } // NullType returns the sql null-type for optional and nullable fields. func (f Field) NullType() string { + if f.Type.ValueScanner() { + return f.Type.String() + } switch f.Type.Type { case field.TypeJSON: return "[]byte" @@ -782,6 +785,12 @@ func (f Field) HasGoType() bool { return f.Type != nil && f.Type.RType != nil } +// ConvertedToBasic indicates if the Go type of the field +// can be converted to basic type (string, int, etc). +func (f Field) ConvertedToBasic() bool { + return !f.HasGoType() || f.BasicType("") != "" +} + var ( nullInt64Type = reflect.TypeOf(sql.NullInt64{}) nullStringType = reflect.TypeOf(sql.NullString{}) diff --git a/entc/integration/ent/fieldtype.go b/entc/integration/ent/fieldtype.go index 839607043..96e5cfa8c 100644 --- a/entc/integration/ent/fieldtype.go +++ b/entc/integration/ent/fieldtype.go @@ -14,6 +14,7 @@ import ( "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/ent/fieldtype" + "github.com/facebookincubator/ent/entc/integration/ent/schema" ) // FieldType is the model entity for the FieldType schema. @@ -76,7 +77,15 @@ type FieldType struct { // Dir holds the value of the "dir" field. Dir http.Dir `json:"dir,omitempty"` // Ndir holds the value of the "ndir" field. - Ndir *http.Dir `json:"ndir,omitempty"` + Ndir *http.Dir `json:"ndir,omitempty"` + // Str holds the value of the "str" field. + Str sql.NullString `json:"str,omitempty"` + // NullStr holds the value of the "null_str" field. + NullStr *sql.NullString `json:"null_str,omitempty"` + // Link holds the value of the "link" field. + Link schema.Link `json:"link,omitempty"` + // NullLink holds the value of the "null_link" field. + NullLink *schema.Link `json:"null_link,omitempty"` file_field *int } @@ -112,6 +121,10 @@ func (*FieldType) scanValues() []interface{} { &sql.NullFloat64{}, // decimal &sql.NullString{}, // dir &sql.NullString{}, // ndir + &sql.NullString{}, // str + &sql.NullString{}, // null_str + &schema.Link{}, // link + &schema.Link{}, // null_link } } @@ -280,7 +293,27 @@ func (ft *FieldType) assignValues(values ...interface{}) error { ft.Ndir = new(http.Dir) *ft.Ndir = http.Dir(value.String) } - values = values[28:] + if value, ok := values[28].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field str", values[28]) + } else if value != nil { + ft.Str = *value + } + if value, ok := values[29].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field null_str", values[29]) + } else if value != nil { + ft.NullStr = value + } + if value, ok := values[30].(*schema.Link); !ok { + return fmt.Errorf("unexpected type %T for field link", values[30]) + } else if value != nil { + ft.Link = *value + } + if value, ok := values[31].(*schema.Link); !ok { + return fmt.Errorf("unexpected type %T for field null_link", values[31]) + } else if value != nil { + ft.NullLink = value + } + values = values[32:] if len(values) == len(fieldtype.ForeignKeys) { if value, ok := values[0].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field file_field", value) @@ -383,6 +416,18 @@ func (ft *FieldType) String() string { builder.WriteString(", ndir=") builder.WriteString(fmt.Sprintf("%v", *v)) } + builder.WriteString(", str=") + builder.WriteString(fmt.Sprintf("%v", ft.Str)) + if v := ft.NullStr; v != nil { + builder.WriteString(", null_str=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", link=") + builder.WriteString(fmt.Sprintf("%v", ft.Link)) + if v := ft.NullLink; v != nil { + builder.WriteString(", null_link=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } builder.WriteByte(')') return builder.String() } diff --git a/entc/integration/ent/fieldtype/fieldtype.go b/entc/integration/ent/fieldtype/fieldtype.go index 233807772..2f76ff077 100644 --- a/entc/integration/ent/fieldtype/fieldtype.go +++ b/entc/integration/ent/fieldtype/fieldtype.go @@ -42,7 +42,11 @@ const ( FieldDatetime = "datetime" // FieldDecimal holds the string denoting the decimal vertex property in the database. FieldDecimal = "decimal" // FieldDir holds the string denoting the dir vertex property in the database. FieldDir = "dir" // FieldNdir holds the string denoting the ndir vertex property in the database. - FieldNdir = "ndir" + FieldNdir = "ndir" // FieldStr holds the string denoting the str vertex property in the database. + FieldStr = "str" // FieldNullStr holds the string denoting the null_str vertex property in the database. + FieldNullStr = "null_str" // FieldLink holds the string denoting the link vertex property in the database. + FieldLink = "link" // FieldNullLink holds the string denoting the null_link vertex property in the database. + FieldNullLink = "null_link" // Table holds the table name of the fieldtype in the database. Table = "field_types" @@ -79,6 +83,10 @@ var Columns = []string{ FieldDecimal, FieldDir, FieldNdir, + FieldStr, + FieldNullStr, + FieldLink, + FieldNullLink, } // ForeignKeys holds the SQL foreign-keys that are owned by the FieldType type. diff --git a/entc/integration/ent/fieldtype/where.go b/entc/integration/ent/fieldtype/where.go index 3999c8c24..a4eedd437 100644 --- a/entc/integration/ent/fieldtype/where.go +++ b/entc/integration/ent/fieldtype/where.go @@ -12,6 +12,7 @@ import ( "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/ent/predicate" + "github.com/facebookincubator/ent/entc/integration/ent/schema" ) // ID filters vertices based on their identifier. @@ -288,6 +289,38 @@ func Ndir(v http.Dir) predicate.FieldType { }) } +// Str applies equality check predicate on the "str" field. It's identical to StrEQ. +func Str(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStr), vc)) + }) +} + +// NullStr applies equality check predicate on the "null_str" field. It's identical to NullStrEQ. +func NullStr(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldNullStr), vc)) + }) +} + +// Link applies equality check predicate on the "link" field. It's identical to LinkEQ. +func Link(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLink), vc)) + }) +} + +// NullLink applies equality check predicate on the "null_link" field. It's identical to NullLinkEQ. +func NullLink(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldNullLink), vc)) + }) +} + // IntEQ applies the EQ predicate on the "int" field. func IntEQ(v int) predicate.FieldType { return predicate.FieldType(func(s *sql.Selector) { @@ -2550,7 +2583,7 @@ func DirNEQ(v http.Dir) predicate.FieldType { func DirIn(vs ...http.Dir) predicate.FieldType { v := make([]interface{}, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, @@ -2567,7 +2600,7 @@ func DirIn(vs ...http.Dir) predicate.FieldType { func DirNotIn(vs ...http.Dir) predicate.FieldType { v := make([]interface{}, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, @@ -2686,7 +2719,7 @@ func NdirNEQ(v http.Dir) predicate.FieldType { func NdirIn(vs ...http.Dir) predicate.FieldType { v := make([]interface{}, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, @@ -2703,7 +2736,7 @@ func NdirIn(vs ...http.Dir) predicate.FieldType { func NdirNotIn(vs ...http.Dir) predicate.FieldType { v := make([]interface{}, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } return predicate.FieldType(func(s *sql.Selector) { // if not arguments were provided, append the FALSE constants, @@ -2802,6 +2835,550 @@ func NdirContainsFold(v http.Dir) predicate.FieldType { }) } +// StrEQ applies the EQ predicate on the "str" field. +func StrEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStr), vc)) + }) +} + +// StrNEQ applies the NEQ predicate on the "str" field. +func StrNEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStr), vc)) + }) +} + +// StrIn applies the In predicate on the "str" field. +func StrIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldStr), v...)) + }) +} + +// StrNotIn applies the NotIn predicate on the "str" field. +func StrNotIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldStr), v...)) + }) +} + +// StrGT applies the GT predicate on the "str" field. +func StrGT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldStr), vc)) + }) +} + +// StrGTE applies the GTE predicate on the "str" field. +func StrGTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldStr), vc)) + }) +} + +// StrLT applies the LT predicate on the "str" field. +func StrLT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldStr), vc)) + }) +} + +// StrLTE applies the LTE predicate on the "str" field. +func StrLTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldStr), vc)) + }) +} + +// StrContains applies the Contains predicate on the "str" field. +func StrContains(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldStr), vc)) + }) +} + +// StrHasPrefix applies the HasPrefix predicate on the "str" field. +func StrHasPrefix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldStr), vc)) + }) +} + +// StrHasSuffix applies the HasSuffix predicate on the "str" field. +func StrHasSuffix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldStr), vc)) + }) +} + +// StrIsNil applies the IsNil predicate on the "str" field. +func StrIsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldStr))) + }) +} + +// StrNotNil applies the NotNil predicate on the "str" field. +func StrNotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldStr))) + }) +} + +// StrEqualFold applies the EqualFold predicate on the "str" field. +func StrEqualFold(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldStr), vc)) + }) +} + +// StrContainsFold applies the ContainsFold predicate on the "str" field. +func StrContainsFold(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldStr), vc)) + }) +} + +// NullStrEQ applies the EQ predicate on the "null_str" field. +func NullStrEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldNullStr), vc)) + }) +} + +// NullStrNEQ applies the NEQ predicate on the "null_str" field. +func NullStrNEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldNullStr), vc)) + }) +} + +// NullStrIn applies the In predicate on the "null_str" field. +func NullStrIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNullStr), v...)) + }) +} + +// NullStrNotIn applies the NotIn predicate on the "null_str" field. +func NullStrNotIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNullStr), v...)) + }) +} + +// NullStrGT applies the GT predicate on the "null_str" field. +func NullStrGT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldNullStr), vc)) + }) +} + +// NullStrGTE applies the GTE predicate on the "null_str" field. +func NullStrGTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldNullStr), vc)) + }) +} + +// NullStrLT applies the LT predicate on the "null_str" field. +func NullStrLT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldNullStr), vc)) + }) +} + +// NullStrLTE applies the LTE predicate on the "null_str" field. +func NullStrLTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldNullStr), vc)) + }) +} + +// NullStrContains applies the Contains predicate on the "null_str" field. +func NullStrContains(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldNullStr), vc)) + }) +} + +// NullStrHasPrefix applies the HasPrefix predicate on the "null_str" field. +func NullStrHasPrefix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldNullStr), vc)) + }) +} + +// NullStrHasSuffix applies the HasSuffix predicate on the "null_str" field. +func NullStrHasSuffix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldNullStr), vc)) + }) +} + +// NullStrIsNil applies the IsNil predicate on the "null_str" field. +func NullStrIsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldNullStr))) + }) +} + +// NullStrNotNil applies the NotNil predicate on the "null_str" field. +func NullStrNotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldNullStr))) + }) +} + +// NullStrEqualFold applies the EqualFold predicate on the "null_str" field. +func NullStrEqualFold(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldNullStr), vc)) + }) +} + +// NullStrContainsFold applies the ContainsFold predicate on the "null_str" field. +func NullStrContainsFold(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldNullStr), vc)) + }) +} + +// LinkEQ applies the EQ predicate on the "link" field. +func LinkEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLink), vc)) + }) +} + +// LinkNEQ applies the NEQ predicate on the "link" field. +func LinkNEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLink), vc)) + }) +} + +// LinkIn applies the In predicate on the "link" field. +func LinkIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldLink), v...)) + }) +} + +// LinkNotIn applies the NotIn predicate on the "link" field. +func LinkNotIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldLink), v...)) + }) +} + +// LinkGT applies the GT predicate on the "link" field. +func LinkGT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldLink), vc)) + }) +} + +// LinkGTE applies the GTE predicate on the "link" field. +func LinkGTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldLink), vc)) + }) +} + +// LinkLT applies the LT predicate on the "link" field. +func LinkLT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldLink), vc)) + }) +} + +// LinkLTE applies the LTE predicate on the "link" field. +func LinkLTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldLink), vc)) + }) +} + +// LinkContains applies the Contains predicate on the "link" field. +func LinkContains(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldLink), vc)) + }) +} + +// LinkHasPrefix applies the HasPrefix predicate on the "link" field. +func LinkHasPrefix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldLink), vc)) + }) +} + +// LinkHasSuffix applies the HasSuffix predicate on the "link" field. +func LinkHasSuffix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldLink), vc)) + }) +} + +// LinkIsNil applies the IsNil predicate on the "link" field. +func LinkIsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldLink))) + }) +} + +// LinkNotNil applies the NotNil predicate on the "link" field. +func LinkNotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldLink))) + }) +} + +// LinkEqualFold applies the EqualFold predicate on the "link" field. +func LinkEqualFold(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldLink), vc)) + }) +} + +// LinkContainsFold applies the ContainsFold predicate on the "link" field. +func LinkContainsFold(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldLink), vc)) + }) +} + +// NullLinkEQ applies the EQ predicate on the "null_link" field. +func NullLinkEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkNEQ applies the NEQ predicate on the "null_link" field. +func NullLinkNEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkIn applies the In predicate on the "null_link" field. +func NullLinkIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNullLink), v...)) + }) +} + +// NullLinkNotIn applies the NotIn predicate on the "null_link" field. +func NullLinkNotIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + 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(v) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNullLink), v...)) + }) +} + +// NullLinkGT applies the GT predicate on the "null_link" field. +func NullLinkGT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkGTE applies the GTE predicate on the "null_link" field. +func NullLinkGTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkLT applies the LT predicate on the "null_link" field. +func NullLinkLT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkLTE applies the LTE predicate on the "null_link" field. +func NullLinkLTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkContains applies the Contains predicate on the "null_link" field. +func NullLinkContains(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkHasPrefix applies the HasPrefix predicate on the "null_link" field. +func NullLinkHasPrefix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkHasSuffix applies the HasSuffix predicate on the "null_link" field. +func NullLinkHasSuffix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkIsNil applies the IsNil predicate on the "null_link" field. +func NullLinkIsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldNullLink))) + }) +} + +// NullLinkNotNil applies the NotNil predicate on the "null_link" field. +func NullLinkNotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldNullLink))) + }) +} + +// NullLinkEqualFold applies the EqualFold predicate on the "null_link" field. +func NullLinkEqualFold(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldNullLink), vc)) + }) +} + +// NullLinkContainsFold applies the ContainsFold predicate on the "null_link" field. +func NullLinkContainsFold(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldNullLink), vc)) + }) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.FieldType) predicate.FieldType { return predicate.FieldType(func(s *sql.Selector) { diff --git a/entc/integration/ent/fieldtype_create.go b/entc/integration/ent/fieldtype_create.go index 4d0ed8b64..77194b6f0 100644 --- a/entc/integration/ent/fieldtype_create.go +++ b/entc/integration/ent/fieldtype_create.go @@ -13,8 +13,10 @@ import ( "net/http" "time" + "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/dialect/sql/sqlgraph" "github.com/facebookincubator/ent/entc/integration/ent/fieldtype" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/schema/field" ) @@ -377,6 +379,30 @@ func (ftc *FieldTypeCreate) SetNillableNdir(h *http.Dir) *FieldTypeCreate { return ftc } +// SetStr sets the str field. +func (ftc *FieldTypeCreate) SetStr(ss sql.NullString) *FieldTypeCreate { + ftc.mutation.SetStr(ss) + return ftc +} + +// SetNullStr sets the null_str field. +func (ftc *FieldTypeCreate) SetNullStr(ss sql.NullString) *FieldTypeCreate { + ftc.mutation.SetNullStr(ss) + return ftc +} + +// SetLink sets the link field. +func (ftc *FieldTypeCreate) SetLink(s schema.Link) *FieldTypeCreate { + ftc.mutation.SetLink(s) + return ftc +} + +// SetNullLink sets the null_link field. +func (ftc *FieldTypeCreate) SetNullLink(s schema.Link) *FieldTypeCreate { + ftc.mutation.SetNullLink(s) + return ftc +} + // Save creates the FieldType in the database. func (ftc *FieldTypeCreate) Save(ctx context.Context) (*FieldType, error) { if _, ok := ftc.mutation.Int(); !ok { @@ -675,6 +701,38 @@ func (ftc *FieldTypeCreate) sqlSave(ctx context.Context) (*FieldType, error) { }) ft.Ndir = &value } + if value, ok := ftc.mutation.Str(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldStr, + }) + ft.Str = value + } + if value, ok := ftc.mutation.NullStr(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldNullStr, + }) + ft.NullStr = &value + } + if value, ok := ftc.mutation.Link(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldLink, + }) + ft.Link = value + } + if value, ok := ftc.mutation.NullLink(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldNullLink, + }) + ft.NullLink = &value + } if err := sqlgraph.CreateNode(ctx, ftc.driver, _spec); err != nil { if cerr, ok := isSQLConstraintError(err); ok { err = cerr diff --git a/entc/integration/ent/fieldtype_update.go b/entc/integration/ent/fieldtype_update.go index 6fff89929..9d6bd63b4 100644 --- a/entc/integration/ent/fieldtype_update.go +++ b/entc/integration/ent/fieldtype_update.go @@ -16,6 +16,7 @@ import ( "github.com/facebookincubator/ent/dialect/sql/sqlgraph" "github.com/facebookincubator/ent/entc/integration/ent/fieldtype" "github.com/facebookincubator/ent/entc/integration/ent/predicate" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/schema/field" ) @@ -691,6 +692,54 @@ func (ftu *FieldTypeUpdate) ClearNdir() *FieldTypeUpdate { return ftu } +// SetStr sets the str field. +func (ftu *FieldTypeUpdate) SetStr(ss sql.NullString) *FieldTypeUpdate { + ftu.mutation.SetStr(ss) + return ftu +} + +// ClearStr clears the value of str. +func (ftu *FieldTypeUpdate) ClearStr() *FieldTypeUpdate { + ftu.mutation.ClearStr() + return ftu +} + +// SetNullStr sets the null_str field. +func (ftu *FieldTypeUpdate) SetNullStr(ss sql.NullString) *FieldTypeUpdate { + ftu.mutation.SetNullStr(ss) + return ftu +} + +// ClearNullStr clears the value of null_str. +func (ftu *FieldTypeUpdate) ClearNullStr() *FieldTypeUpdate { + ftu.mutation.ClearNullStr() + return ftu +} + +// SetLink sets the link field. +func (ftu *FieldTypeUpdate) SetLink(s schema.Link) *FieldTypeUpdate { + ftu.mutation.SetLink(s) + return ftu +} + +// ClearLink clears the value of link. +func (ftu *FieldTypeUpdate) ClearLink() *FieldTypeUpdate { + ftu.mutation.ClearLink() + return ftu +} + +// SetNullLink sets the null_link field. +func (ftu *FieldTypeUpdate) SetNullLink(s schema.Link) *FieldTypeUpdate { + ftu.mutation.SetNullLink(s) + return ftu +} + +// ClearNullLink clears the value of null_link. +func (ftu *FieldTypeUpdate) ClearNullLink() *FieldTypeUpdate { + ftu.mutation.ClearNullLink() + return ftu +} + // Save executes the query and returns the number of rows/vertices matched by this operation. func (ftu *FieldTypeUpdate) Save(ctx context.Context) (int, error) { if v, ok := ftu.mutation.ValidateOptionalInt32(); ok { @@ -1272,6 +1321,58 @@ func (ftu *FieldTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: fieldtype.FieldNdir, }) } + if value, ok := ftu.mutation.Str(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldStr, + }) + } + if ftu.mutation.StrCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldStr, + }) + } + if value, ok := ftu.mutation.NullStr(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldNullStr, + }) + } + if ftu.mutation.NullStrCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldNullStr, + }) + } + if value, ok := ftu.mutation.Link(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldLink, + }) + } + if ftu.mutation.LinkCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldLink, + }) + } + if value, ok := ftu.mutation.NullLink(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldNullLink, + }) + } + if ftu.mutation.NullLinkCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldNullLink, + }) + } if n, err = sqlgraph.UpdateNodes(ctx, ftu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{fieldtype.Label} @@ -1948,6 +2049,54 @@ func (ftuo *FieldTypeUpdateOne) ClearNdir() *FieldTypeUpdateOne { return ftuo } +// SetStr sets the str field. +func (ftuo *FieldTypeUpdateOne) SetStr(ss sql.NullString) *FieldTypeUpdateOne { + ftuo.mutation.SetStr(ss) + return ftuo +} + +// ClearStr clears the value of str. +func (ftuo *FieldTypeUpdateOne) ClearStr() *FieldTypeUpdateOne { + ftuo.mutation.ClearStr() + return ftuo +} + +// SetNullStr sets the null_str field. +func (ftuo *FieldTypeUpdateOne) SetNullStr(ss sql.NullString) *FieldTypeUpdateOne { + ftuo.mutation.SetNullStr(ss) + return ftuo +} + +// ClearNullStr clears the value of null_str. +func (ftuo *FieldTypeUpdateOne) ClearNullStr() *FieldTypeUpdateOne { + ftuo.mutation.ClearNullStr() + return ftuo +} + +// SetLink sets the link field. +func (ftuo *FieldTypeUpdateOne) SetLink(s schema.Link) *FieldTypeUpdateOne { + ftuo.mutation.SetLink(s) + return ftuo +} + +// ClearLink clears the value of link. +func (ftuo *FieldTypeUpdateOne) ClearLink() *FieldTypeUpdateOne { + ftuo.mutation.ClearLink() + return ftuo +} + +// SetNullLink sets the null_link field. +func (ftuo *FieldTypeUpdateOne) SetNullLink(s schema.Link) *FieldTypeUpdateOne { + ftuo.mutation.SetNullLink(s) + return ftuo +} + +// ClearNullLink clears the value of null_link. +func (ftuo *FieldTypeUpdateOne) ClearNullLink() *FieldTypeUpdateOne { + ftuo.mutation.ClearNullLink() + return ftuo +} + // Save executes the query and returns the updated entity. func (ftuo *FieldTypeUpdateOne) Save(ctx context.Context) (*FieldType, error) { if v, ok := ftuo.mutation.ValidateOptionalInt32(); ok { @@ -2527,6 +2676,58 @@ func (ftuo *FieldTypeUpdateOne) sqlSave(ctx context.Context) (ft *FieldType, err Column: fieldtype.FieldNdir, }) } + if value, ok := ftuo.mutation.Str(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldStr, + }) + } + if ftuo.mutation.StrCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldStr, + }) + } + if value, ok := ftuo.mutation.NullStr(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldNullStr, + }) + } + if ftuo.mutation.NullStrCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldNullStr, + }) + } + if value, ok := ftuo.mutation.Link(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldLink, + }) + } + if ftuo.mutation.LinkCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldLink, + }) + } + if value, ok := ftuo.mutation.NullLink(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: fieldtype.FieldNullLink, + }) + } + if ftuo.mutation.NullLinkCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: fieldtype.FieldNullLink, + }) + } ft = &FieldType{config: ftuo.config} _spec.Assign = ft.assignValues _spec.ScanValues = ft.scanValues() diff --git a/entc/integration/ent/migrate/schema.go b/entc/integration/ent/migrate/schema.go index ce6e8f8ba..43f8f2f85 100644 --- a/entc/integration/ent/migrate/schema.go +++ b/entc/integration/ent/migrate/schema.go @@ -81,6 +81,10 @@ var ( {Name: "decimal", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"mysql": "decimal(6,2)", "postgres": "numeric"}}, {Name: "dir", Type: field.TypeString, Nullable: true}, {Name: "ndir", Type: field.TypeString, Nullable: true}, + {Name: "str", Type: field.TypeString, Nullable: true}, + {Name: "null_str", Type: field.TypeString, Nullable: true}, + {Name: "link", Type: field.TypeString, Nullable: true}, + {Name: "null_link", Type: field.TypeString, Nullable: true}, {Name: "file_field", Type: field.TypeInt, Nullable: true}, } // FieldTypesTable holds the schema information for the "field_types" table. @@ -91,7 +95,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "field_types_files_field", - Columns: []*schema.Column{FieldTypesColumns[29]}, + Columns: []*schema.Column{FieldTypesColumns[33]}, RefColumns: []*schema.Column{FilesColumns[0]}, OnDelete: schema.SetNull, diff --git a/entc/integration/ent/mutation.go b/entc/integration/ent/mutation.go index 4b0ac89cc..64ca4e3fc 100644 --- a/entc/integration/ent/mutation.go +++ b/entc/integration/ent/mutation.go @@ -13,6 +13,7 @@ import ( "sync" "time" + "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/ent/card" "github.com/facebookincubator/ent/entc/integration/ent/comment" "github.com/facebookincubator/ent/entc/integration/ent/fieldtype" @@ -22,6 +23,7 @@ import ( "github.com/facebookincubator/ent/entc/integration/ent/groupinfo" "github.com/facebookincubator/ent/entc/integration/ent/node" "github.com/facebookincubator/ent/entc/integration/ent/pet" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/entc/integration/ent/spec" "github.com/facebookincubator/ent/entc/integration/ent/user" @@ -1252,6 +1254,10 @@ type FieldTypeMutation struct { adddecimal *float64 dir *http.Dir ndir *http.Dir + str *sql.NullString + null_str *sql.NullString + link *schema.Link + null_link *schema.Link clearedFields map[string]struct{} done bool oldValue func(context.Context) (*FieldType, error) @@ -3170,6 +3176,206 @@ func (m *FieldTypeMutation) ResetNdir() { delete(m.clearedFields, fieldtype.FieldNdir) } +// SetStr sets the str field. +func (m *FieldTypeMutation) SetStr(ss sql.NullString) { + m.str = &ss +} + +// Str returns the str value in the mutation. +func (m *FieldTypeMutation) Str() (r sql.NullString, exists bool) { + v := m.str + if v == nil { + return + } + return *v, true +} + +// OldStr returns the old str value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldStr(ctx context.Context) (v sql.NullString, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldStr is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldStr requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStr: %w", err) + } + return oldValue.Str, nil +} + +// ClearStr clears the value of str. +func (m *FieldTypeMutation) ClearStr() { + m.str = nil + m.clearedFields[fieldtype.FieldStr] = struct{}{} +} + +// StrCleared returns if the field str was cleared in this mutation. +func (m *FieldTypeMutation) StrCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldStr] + return ok +} + +// ResetStr reset all changes of the "str" field. +func (m *FieldTypeMutation) ResetStr() { + m.str = nil + delete(m.clearedFields, fieldtype.FieldStr) +} + +// SetNullStr sets the null_str field. +func (m *FieldTypeMutation) SetNullStr(ss sql.NullString) { + m.null_str = &ss +} + +// NullStr returns the null_str value in the mutation. +func (m *FieldTypeMutation) NullStr() (r sql.NullString, exists bool) { + v := m.null_str + if v == nil { + return + } + return *v, true +} + +// OldNullStr returns the old null_str value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldNullStr(ctx context.Context) (v *sql.NullString, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldNullStr is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldNullStr requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNullStr: %w", err) + } + return oldValue.NullStr, nil +} + +// ClearNullStr clears the value of null_str. +func (m *FieldTypeMutation) ClearNullStr() { + m.null_str = nil + m.clearedFields[fieldtype.FieldNullStr] = struct{}{} +} + +// NullStrCleared returns if the field null_str was cleared in this mutation. +func (m *FieldTypeMutation) NullStrCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldNullStr] + return ok +} + +// ResetNullStr reset all changes of the "null_str" field. +func (m *FieldTypeMutation) ResetNullStr() { + m.null_str = nil + delete(m.clearedFields, fieldtype.FieldNullStr) +} + +// SetLink sets the link field. +func (m *FieldTypeMutation) SetLink(s schema.Link) { + m.link = &s +} + +// Link returns the link value in the mutation. +func (m *FieldTypeMutation) Link() (r schema.Link, exists bool) { + v := m.link + if v == nil { + return + } + return *v, true +} + +// OldLink returns the old link value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldLink(ctx context.Context) (v schema.Link, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldLink is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLink: %w", err) + } + return oldValue.Link, nil +} + +// ClearLink clears the value of link. +func (m *FieldTypeMutation) ClearLink() { + m.link = nil + m.clearedFields[fieldtype.FieldLink] = struct{}{} +} + +// LinkCleared returns if the field link was cleared in this mutation. +func (m *FieldTypeMutation) LinkCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldLink] + return ok +} + +// ResetLink reset all changes of the "link" field. +func (m *FieldTypeMutation) ResetLink() { + m.link = nil + delete(m.clearedFields, fieldtype.FieldLink) +} + +// SetNullLink sets the null_link field. +func (m *FieldTypeMutation) SetNullLink(s schema.Link) { + m.null_link = &s +} + +// NullLink returns the null_link value in the mutation. +func (m *FieldTypeMutation) NullLink() (r schema.Link, exists bool) { + v := m.null_link + if v == nil { + return + } + return *v, true +} + +// OldNullLink returns the old null_link value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldNullLink(ctx context.Context) (v *schema.Link, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldNullLink is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldNullLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNullLink: %w", err) + } + return oldValue.NullLink, nil +} + +// ClearNullLink clears the value of null_link. +func (m *FieldTypeMutation) ClearNullLink() { + m.null_link = nil + m.clearedFields[fieldtype.FieldNullLink] = struct{}{} +} + +// NullLinkCleared returns if the field null_link was cleared in this mutation. +func (m *FieldTypeMutation) NullLinkCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldNullLink] + return ok +} + +// ResetNullLink reset all changes of the "null_link" field. +func (m *FieldTypeMutation) ResetNullLink() { + m.null_link = nil + delete(m.clearedFields, fieldtype.FieldNullLink) +} + // Op returns the operation name. func (m *FieldTypeMutation) Op() Op { return m.op @@ -3184,7 +3390,7 @@ func (m *FieldTypeMutation) Type() string { // this mutation. Note that, in order to get all numeric // fields that were in/decremented, call AddedFields(). func (m *FieldTypeMutation) Fields() []string { - fields := make([]string, 0, 28) + fields := make([]string, 0, 32) if m.int != nil { fields = append(fields, fieldtype.FieldInt) } @@ -3269,6 +3475,18 @@ func (m *FieldTypeMutation) Fields() []string { if m.ndir != nil { fields = append(fields, fieldtype.FieldNdir) } + if m.str != nil { + fields = append(fields, fieldtype.FieldStr) + } + if m.null_str != nil { + fields = append(fields, fieldtype.FieldNullStr) + } + if m.link != nil { + fields = append(fields, fieldtype.FieldLink) + } + if m.null_link != nil { + fields = append(fields, fieldtype.FieldNullLink) + } return fields } @@ -3333,6 +3551,14 @@ func (m *FieldTypeMutation) Field(name string) (ent.Value, bool) { return m.Dir() case fieldtype.FieldNdir: return m.Ndir() + case fieldtype.FieldStr: + return m.Str() + case fieldtype.FieldNullStr: + return m.NullStr() + case fieldtype.FieldLink: + return m.Link() + case fieldtype.FieldNullLink: + return m.NullLink() } return nil, false } @@ -3398,6 +3624,14 @@ func (m *FieldTypeMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldDir(ctx) case fieldtype.FieldNdir: return m.OldNdir(ctx) + case fieldtype.FieldStr: + return m.OldStr(ctx) + case fieldtype.FieldNullStr: + return m.OldNullStr(ctx) + case fieldtype.FieldLink: + return m.OldLink(ctx) + case fieldtype.FieldNullLink: + return m.OldNullLink(ctx) } return nil, fmt.Errorf("unknown FieldType field %s", name) } @@ -3603,6 +3837,34 @@ func (m *FieldTypeMutation) SetField(name string, value ent.Value) error { } m.SetNdir(v) return nil + case fieldtype.FieldStr: + v, ok := value.(sql.NullString) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStr(v) + return nil + case fieldtype.FieldNullStr: + v, ok := value.(sql.NullString) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNullStr(v) + return nil + case fieldtype.FieldLink: + v, ok := value.(schema.Link) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLink(v) + return nil + case fieldtype.FieldNullLink: + v, ok := value.(schema.Link) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNullLink(v) + return nil } return fmt.Errorf("unknown FieldType field %s", name) } @@ -3993,6 +4255,18 @@ func (m *FieldTypeMutation) ClearedFields() []string { if m.FieldCleared(fieldtype.FieldNdir) { fields = append(fields, fieldtype.FieldNdir) } + if m.FieldCleared(fieldtype.FieldStr) { + fields = append(fields, fieldtype.FieldStr) + } + if m.FieldCleared(fieldtype.FieldNullStr) { + fields = append(fields, fieldtype.FieldNullStr) + } + if m.FieldCleared(fieldtype.FieldLink) { + fields = append(fields, fieldtype.FieldLink) + } + if m.FieldCleared(fieldtype.FieldNullLink) { + fields = append(fields, fieldtype.FieldNullLink) + } return fields } @@ -4076,6 +4350,18 @@ func (m *FieldTypeMutation) ClearField(name string) error { case fieldtype.FieldNdir: m.ClearNdir() return nil + case fieldtype.FieldStr: + m.ClearStr() + return nil + case fieldtype.FieldNullStr: + m.ClearNullStr() + return nil + case fieldtype.FieldLink: + m.ClearLink() + return nil + case fieldtype.FieldNullLink: + m.ClearNullLink() + return nil } return fmt.Errorf("unknown FieldType nullable field %s", name) } @@ -4169,6 +4455,18 @@ func (m *FieldTypeMutation) ResetField(name string) error { case fieldtype.FieldNdir: m.ResetNdir() return nil + case fieldtype.FieldStr: + m.ResetStr() + return nil + case fieldtype.FieldNullStr: + m.ResetNullStr() + return nil + case fieldtype.FieldLink: + m.ResetLink() + return nil + case fieldtype.FieldNullLink: + m.ResetNullLink() + return nil } return fmt.Errorf("unknown FieldType field %s", name) } diff --git a/entc/integration/ent/schema/fieldtype.go b/entc/integration/ent/schema/fieldtype.go index cc5bff01a..54c5bce34 100644 --- a/entc/integration/ent/schema/fieldtype.go +++ b/entc/integration/ent/schema/fieldtype.go @@ -5,10 +5,14 @@ package schema import ( + "database/sql/driver" + "fmt" "net/http" + "net/url" "github.com/facebookincubator/ent" "github.com/facebookincubator/ent/dialect" + "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/schema/field" ) @@ -68,5 +72,45 @@ func (FieldType) Fields() []ent.Field { Optional(). Nillable(). GoType(http.Dir("ndir")), + field.String("str"). + Optional(). + GoType(&sql.NullString{}), + field.String("null_str"). + Optional(). + Nillable(). + GoType(&sql.NullString{}), + field.String("link"). + Optional(). + GoType(&Link{}), + field.String("null_link"). + Optional(). + Nillable(). + GoType(&Link{}), } } + +type Link struct { + *url.URL +} + +// Scan implements the Scanner interface. +func (l *Link) Scan(value interface{}) (err error) { + switch v := value.(type) { + case nil: + case []byte: + l.URL, err = url.Parse(string(v)) + case string: + l.URL, err = url.Parse(v) + default: + err = fmt.Errorf("unexpcted type %T", v) + } + return +} + +// Value implements the driver Valuer interface. +func (l Link) Value() (driver.Value, error) { + if l.URL == nil { + return nil, nil + } + return l.String(), nil +} diff --git a/entc/integration/gremlin/ent/fieldtype.go b/entc/integration/gremlin/ent/fieldtype.go index ddbb9a08a..aa4e1ea0d 100644 --- a/entc/integration/gremlin/ent/fieldtype.go +++ b/entc/integration/gremlin/ent/fieldtype.go @@ -7,12 +7,14 @@ package ent import ( + "database/sql" "fmt" "net/http" "strings" "time" "github.com/facebookincubator/ent/dialect/gremlin" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/fieldtype" ) @@ -75,6 +77,16 @@ type FieldType struct { Decimal float64 `json:"decimal,omitempty"` // Dir holds the value of the "dir" field. Dir http.Dir `json:"dir,omitempty"` + // Ndir holds the value of the "ndir" field. + Ndir *http.Dir `json:"ndir,omitempty"` + // Str holds the value of the "str" field. + Str sql.NullString `json:"str,omitempty"` + // NullStr holds the value of the "null_str" field. + NullStr *sql.NullString `json:"null_str,omitempty"` + // Link holds the value of the "link" field. + Link schema.Link `json:"link,omitempty"` + // NullLink holds the value of the "null_link" field. + NullLink *schema.Link `json:"null_link,omitempty"` } // FromResponse scans the gremlin response data into FieldType. @@ -112,6 +124,11 @@ func (ft *FieldType) FromResponse(res *gremlin.Response) error { Datetime int64 `json:"datetime,omitempty"` Decimal float64 `json:"decimal,omitempty"` Dir http.Dir `json:"dir,omitempty"` + Ndir *http.Dir `json:"ndir,omitempty"` + Str sql.NullString `json:"str,omitempty"` + NullStr *sql.NullString `json:"null_str,omitempty"` + Link schema.Link `json:"link,omitempty"` + NullLink *schema.Link `json:"null_link,omitempty"` } if err := vmap.Decode(&scanft); err != nil { return err @@ -144,6 +161,11 @@ func (ft *FieldType) FromResponse(res *gremlin.Response) error { ft.Datetime = time.Unix(0, scanft.Datetime) ft.Decimal = scanft.Decimal ft.Dir = scanft.Dir + ft.Ndir = scanft.Ndir + ft.Str = scanft.Str + ft.NullStr = scanft.NullStr + ft.Link = scanft.Link + ft.NullLink = scanft.NullLink return nil } @@ -234,6 +256,22 @@ func (ft *FieldType) String() string { builder.WriteString(fmt.Sprintf("%v", ft.Decimal)) builder.WriteString(", dir=") builder.WriteString(fmt.Sprintf("%v", ft.Dir)) + if v := ft.Ndir; v != nil { + builder.WriteString(", ndir=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", str=") + builder.WriteString(fmt.Sprintf("%v", ft.Str)) + if v := ft.NullStr; v != nil { + builder.WriteString(", null_str=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", link=") + builder.WriteString(fmt.Sprintf("%v", ft.Link)) + if v := ft.NullLink; v != nil { + builder.WriteString(", null_link=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } builder.WriteByte(')') return builder.String() } @@ -276,6 +314,11 @@ func (ft *FieldTypes) FromResponse(res *gremlin.Response) error { Datetime int64 `json:"datetime,omitempty"` Decimal float64 `json:"decimal,omitempty"` Dir http.Dir `json:"dir,omitempty"` + Ndir *http.Dir `json:"ndir,omitempty"` + Str sql.NullString `json:"str,omitempty"` + NullStr *sql.NullString `json:"null_str,omitempty"` + Link schema.Link `json:"link,omitempty"` + NullLink *schema.Link `json:"null_link,omitempty"` } if err := vmap.Decode(&scanft); err != nil { return err @@ -310,6 +353,11 @@ func (ft *FieldTypes) FromResponse(res *gremlin.Response) error { Datetime: time.Unix(0, v.Datetime), Decimal: v.Decimal, Dir: v.Dir, + Ndir: v.Ndir, + Str: v.Str, + NullStr: v.NullStr, + Link: v.Link, + NullLink: v.NullLink, }) } return nil diff --git a/entc/integration/gremlin/ent/fieldtype/fieldtype.go b/entc/integration/gremlin/ent/fieldtype/fieldtype.go index 263a8e11f..4d6a05294 100644 --- a/entc/integration/gremlin/ent/fieldtype/fieldtype.go +++ b/entc/integration/gremlin/ent/fieldtype/fieldtype.go @@ -41,7 +41,12 @@ const ( FieldOptionalFloat32 = "optional_float32" // FieldDatetime holds the string denoting the datetime vertex property in the database. FieldDatetime = "datetime" // FieldDecimal holds the string denoting the decimal vertex property in the database. FieldDecimal = "decimal" // FieldDir holds the string denoting the dir vertex property in the database. - FieldDir = "dir" + FieldDir = "dir" // FieldNdir holds the string denoting the ndir vertex property in the database. + FieldNdir = "ndir" // FieldStr holds the string denoting the str vertex property in the database. + FieldStr = "str" // FieldNullStr holds the string denoting the null_str vertex property in the database. + FieldNullStr = "null_str" // FieldLink holds the string denoting the link vertex property in the database. + FieldLink = "link" // FieldNullLink holds the string denoting the null_link vertex property in the database. + FieldNullLink = "null_link" ) var ( diff --git a/entc/integration/gremlin/ent/fieldtype/where.go b/entc/integration/gremlin/ent/fieldtype/where.go index e7f356a38..7db6b47e9 100644 --- a/entc/integration/gremlin/ent/fieldtype/where.go +++ b/entc/integration/gremlin/ent/fieldtype/where.go @@ -7,12 +7,14 @@ package fieldtype import ( + "database/sql" "net/http" "time" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/__" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/p" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/predicate" ) @@ -270,6 +272,46 @@ func Dir(v http.Dir) predicate.FieldType { }) } +// Ndir applies equality check predicate on the "ndir" field. It's identical to NdirEQ. +func Ndir(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.EQ(vc)) + }) +} + +// Str applies equality check predicate on the "str" field. It's identical to StrEQ. +func Str(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.EQ(vc)) + }) +} + +// NullStr applies equality check predicate on the "null_str" field. It's identical to NullStrEQ. +func NullStr(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.EQ(vc)) + }) +} + +// Link applies equality check predicate on the "link" field. It's identical to LinkEQ. +func Link(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.EQ(vc)) + }) +} + +// NullLink applies equality check predicate on the "null_link" field. It's identical to NullLinkEQ. +func NullLink(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.EQ(vc)) + }) +} + // IntEQ applies the EQ predicate on the "int" field. func IntEQ(v int) predicate.FieldType { return predicate.FieldType(func(t *dsl.Traversal) { @@ -2220,7 +2262,7 @@ func DirNEQ(v http.Dir) predicate.FieldType { func DirIn(vs ...http.Dir) predicate.FieldType { v := make([]interface{}, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldDir, p.Within(v...)) @@ -2231,7 +2273,7 @@ func DirIn(vs ...http.Dir) predicate.FieldType { func DirNotIn(vs ...http.Dir) predicate.FieldType { v := make([]interface{}, len(vs)) for i := range v { - v[i] = vs[i] + v[i] = string(vs[i]) } return predicate.FieldType(func(t *dsl.Traversal) { t.Has(Label, FieldDir, p.Without(v...)) @@ -2308,6 +2350,546 @@ func DirNotNil() predicate.FieldType { }) } +// NdirEQ applies the EQ predicate on the "ndir" field. +func NdirEQ(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.EQ(vc)) + }) +} + +// NdirNEQ applies the NEQ predicate on the "ndir" field. +func NdirNEQ(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.NEQ(vc)) + }) +} + +// NdirIn applies the In predicate on the "ndir" field. +func NdirIn(vs ...http.Dir) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.Within(v...)) + }) +} + +// NdirNotIn applies the NotIn predicate on the "ndir" field. +func NdirNotIn(vs ...http.Dir) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = string(vs[i]) + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.Without(v...)) + }) +} + +// NdirGT applies the GT predicate on the "ndir" field. +func NdirGT(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.GT(vc)) + }) +} + +// NdirGTE applies the GTE predicate on the "ndir" field. +func NdirGTE(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.GTE(vc)) + }) +} + +// NdirLT applies the LT predicate on the "ndir" field. +func NdirLT(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.LT(vc)) + }) +} + +// NdirLTE applies the LTE predicate on the "ndir" field. +func NdirLTE(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.LTE(vc)) + }) +} + +// NdirContains applies the Contains predicate on the "ndir" field. +func NdirContains(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.Containing(vc)) + }) +} + +// NdirHasPrefix applies the HasPrefix predicate on the "ndir" field. +func NdirHasPrefix(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.StartingWith(vc)) + }) +} + +// NdirHasSuffix applies the HasSuffix predicate on the "ndir" field. +func NdirHasSuffix(v http.Dir) predicate.FieldType { + vc := string(v) + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNdir, p.EndingWith(vc)) + }) +} + +// NdirIsNil applies the IsNil predicate on the "ndir" field. +func NdirIsNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).HasNot(FieldNdir) + }) +} + +// NdirNotNil applies the NotNil predicate on the "ndir" field. +func NdirNotNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).Has(FieldNdir) + }) +} + +// StrEQ applies the EQ predicate on the "str" field. +func StrEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.EQ(vc)) + }) +} + +// StrNEQ applies the NEQ predicate on the "str" field. +func StrNEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.NEQ(vc)) + }) +} + +// StrIn applies the In predicate on the "str" field. +func StrIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.Within(v...)) + }) +} + +// StrNotIn applies the NotIn predicate on the "str" field. +func StrNotIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.Without(v...)) + }) +} + +// StrGT applies the GT predicate on the "str" field. +func StrGT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.GT(vc)) + }) +} + +// StrGTE applies the GTE predicate on the "str" field. +func StrGTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.GTE(vc)) + }) +} + +// StrLT applies the LT predicate on the "str" field. +func StrLT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.LT(vc)) + }) +} + +// StrLTE applies the LTE predicate on the "str" field. +func StrLTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.LTE(vc)) + }) +} + +// StrContains applies the Contains predicate on the "str" field. +func StrContains(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.Containing(vc)) + }) +} + +// StrHasPrefix applies the HasPrefix predicate on the "str" field. +func StrHasPrefix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.StartingWith(vc)) + }) +} + +// StrHasSuffix applies the HasSuffix predicate on the "str" field. +func StrHasSuffix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldStr, p.EndingWith(vc)) + }) +} + +// StrIsNil applies the IsNil predicate on the "str" field. +func StrIsNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).HasNot(FieldStr) + }) +} + +// StrNotNil applies the NotNil predicate on the "str" field. +func StrNotNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).Has(FieldStr) + }) +} + +// NullStrEQ applies the EQ predicate on the "null_str" field. +func NullStrEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.EQ(vc)) + }) +} + +// NullStrNEQ applies the NEQ predicate on the "null_str" field. +func NullStrNEQ(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.NEQ(vc)) + }) +} + +// NullStrIn applies the In predicate on the "null_str" field. +func NullStrIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.Within(v...)) + }) +} + +// NullStrNotIn applies the NotIn predicate on the "null_str" field. +func NullStrNotIn(vs ...sql.NullString) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.Without(v...)) + }) +} + +// NullStrGT applies the GT predicate on the "null_str" field. +func NullStrGT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.GT(vc)) + }) +} + +// NullStrGTE applies the GTE predicate on the "null_str" field. +func NullStrGTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.GTE(vc)) + }) +} + +// NullStrLT applies the LT predicate on the "null_str" field. +func NullStrLT(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.LT(vc)) + }) +} + +// NullStrLTE applies the LTE predicate on the "null_str" field. +func NullStrLTE(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.LTE(vc)) + }) +} + +// NullStrContains applies the Contains predicate on the "null_str" field. +func NullStrContains(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.Containing(vc)) + }) +} + +// NullStrHasPrefix applies the HasPrefix predicate on the "null_str" field. +func NullStrHasPrefix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.StartingWith(vc)) + }) +} + +// NullStrHasSuffix applies the HasSuffix predicate on the "null_str" field. +func NullStrHasSuffix(v sql.NullString) predicate.FieldType { + vc := v.String + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullStr, p.EndingWith(vc)) + }) +} + +// NullStrIsNil applies the IsNil predicate on the "null_str" field. +func NullStrIsNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).HasNot(FieldNullStr) + }) +} + +// NullStrNotNil applies the NotNil predicate on the "null_str" field. +func NullStrNotNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).Has(FieldNullStr) + }) +} + +// LinkEQ applies the EQ predicate on the "link" field. +func LinkEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.EQ(vc)) + }) +} + +// LinkNEQ applies the NEQ predicate on the "link" field. +func LinkNEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.NEQ(vc)) + }) +} + +// LinkIn applies the In predicate on the "link" field. +func LinkIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.Within(v...)) + }) +} + +// LinkNotIn applies the NotIn predicate on the "link" field. +func LinkNotIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.Without(v...)) + }) +} + +// LinkGT applies the GT predicate on the "link" field. +func LinkGT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.GT(vc)) + }) +} + +// LinkGTE applies the GTE predicate on the "link" field. +func LinkGTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.GTE(vc)) + }) +} + +// LinkLT applies the LT predicate on the "link" field. +func LinkLT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.LT(vc)) + }) +} + +// LinkLTE applies the LTE predicate on the "link" field. +func LinkLTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.LTE(vc)) + }) +} + +// LinkContains applies the Contains predicate on the "link" field. +func LinkContains(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.Containing(vc)) + }) +} + +// LinkHasPrefix applies the HasPrefix predicate on the "link" field. +func LinkHasPrefix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.StartingWith(vc)) + }) +} + +// LinkHasSuffix applies the HasSuffix predicate on the "link" field. +func LinkHasSuffix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldLink, p.EndingWith(vc)) + }) +} + +// LinkIsNil applies the IsNil predicate on the "link" field. +func LinkIsNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).HasNot(FieldLink) + }) +} + +// LinkNotNil applies the NotNil predicate on the "link" field. +func LinkNotNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).Has(FieldLink) + }) +} + +// NullLinkEQ applies the EQ predicate on the "null_link" field. +func NullLinkEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.EQ(vc)) + }) +} + +// NullLinkNEQ applies the NEQ predicate on the "null_link" field. +func NullLinkNEQ(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.NEQ(vc)) + }) +} + +// NullLinkIn applies the In predicate on the "null_link" field. +func NullLinkIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.Within(v...)) + }) +} + +// NullLinkNotIn applies the NotIn predicate on the "null_link" field. +func NullLinkNotIn(vs ...schema.Link) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i].String() + } + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.Without(v...)) + }) +} + +// NullLinkGT applies the GT predicate on the "null_link" field. +func NullLinkGT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.GT(vc)) + }) +} + +// NullLinkGTE applies the GTE predicate on the "null_link" field. +func NullLinkGTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.GTE(vc)) + }) +} + +// NullLinkLT applies the LT predicate on the "null_link" field. +func NullLinkLT(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.LT(vc)) + }) +} + +// NullLinkLTE applies the LTE predicate on the "null_link" field. +func NullLinkLTE(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.LTE(vc)) + }) +} + +// NullLinkContains applies the Contains predicate on the "null_link" field. +func NullLinkContains(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.Containing(vc)) + }) +} + +// NullLinkHasPrefix applies the HasPrefix predicate on the "null_link" field. +func NullLinkHasPrefix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.StartingWith(vc)) + }) +} + +// NullLinkHasSuffix applies the HasSuffix predicate on the "null_link" field. +func NullLinkHasSuffix(v schema.Link) predicate.FieldType { + vc := v.String() + return predicate.FieldType(func(t *dsl.Traversal) { + t.Has(Label, FieldNullLink, p.EndingWith(vc)) + }) +} + +// NullLinkIsNil applies the IsNil predicate on the "null_link" field. +func NullLinkIsNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).HasNot(FieldNullLink) + }) +} + +// NullLinkNotNil applies the NotNil predicate on the "null_link" field. +func NullLinkNotNil() predicate.FieldType { + return predicate.FieldType(func(t *dsl.Traversal) { + t.HasLabel(Label).Has(FieldNullLink) + }) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.FieldType) predicate.FieldType { return predicate.FieldType(func(tr *dsl.Traversal) { diff --git a/entc/integration/gremlin/ent/fieldtype_create.go b/entc/integration/gremlin/ent/fieldtype_create.go index 61d0154d1..641a5b1e5 100644 --- a/entc/integration/gremlin/ent/fieldtype_create.go +++ b/entc/integration/gremlin/ent/fieldtype_create.go @@ -8,6 +8,7 @@ package ent import ( "context" + "database/sql" "errors" "fmt" "net/http" @@ -16,6 +17,7 @@ import ( "github.com/facebookincubator/ent/dialect/gremlin" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/g" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/fieldtype" ) @@ -364,6 +366,44 @@ func (ftc *FieldTypeCreate) SetNillableDir(h *http.Dir) *FieldTypeCreate { return ftc } +// SetNdir sets the ndir field. +func (ftc *FieldTypeCreate) SetNdir(h http.Dir) *FieldTypeCreate { + ftc.mutation.SetNdir(h) + return ftc +} + +// SetNillableNdir sets the ndir field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableNdir(h *http.Dir) *FieldTypeCreate { + if h != nil { + ftc.SetNdir(*h) + } + return ftc +} + +// SetStr sets the str field. +func (ftc *FieldTypeCreate) SetStr(ss sql.NullString) *FieldTypeCreate { + ftc.mutation.SetStr(ss) + return ftc +} + +// SetNullStr sets the null_str field. +func (ftc *FieldTypeCreate) SetNullStr(ss sql.NullString) *FieldTypeCreate { + ftc.mutation.SetNullStr(ss) + return ftc +} + +// SetLink sets the link field. +func (ftc *FieldTypeCreate) SetLink(s schema.Link) *FieldTypeCreate { + ftc.mutation.SetLink(s) + return ftc +} + +// SetNullLink sets the null_link field. +func (ftc *FieldTypeCreate) SetNullLink(s schema.Link) *FieldTypeCreate { + ftc.mutation.SetNullLink(s) + return ftc +} + // Save creates the FieldType in the database. func (ftc *FieldTypeCreate) Save(ctx context.Context) (*FieldType, error) { if _, ok := ftc.mutation.Int(); !ok { @@ -526,5 +566,20 @@ func (ftc *FieldTypeCreate) gremlin() *dsl.Traversal { if value, ok := ftc.mutation.Dir(); ok { v.Property(dsl.Single, fieldtype.FieldDir, value) } + if value, ok := ftc.mutation.Ndir(); ok { + v.Property(dsl.Single, fieldtype.FieldNdir, value) + } + if value, ok := ftc.mutation.Str(); ok { + v.Property(dsl.Single, fieldtype.FieldStr, value) + } + if value, ok := ftc.mutation.NullStr(); ok { + v.Property(dsl.Single, fieldtype.FieldNullStr, value) + } + if value, ok := ftc.mutation.Link(); ok { + v.Property(dsl.Single, fieldtype.FieldLink, value) + } + if value, ok := ftc.mutation.NullLink(); ok { + v.Property(dsl.Single, fieldtype.FieldNullLink, value) + } return v.ValueMap(true) } diff --git a/entc/integration/gremlin/ent/fieldtype_update.go b/entc/integration/gremlin/ent/fieldtype_update.go index 7d7abb636..4e57ed6d8 100644 --- a/entc/integration/gremlin/ent/fieldtype_update.go +++ b/entc/integration/gremlin/ent/fieldtype_update.go @@ -8,6 +8,7 @@ package ent import ( "context" + "database/sql" "fmt" "net/http" "time" @@ -16,6 +17,7 @@ import ( "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/__" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/g" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/fieldtype" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/predicate" ) @@ -672,6 +674,74 @@ func (ftu *FieldTypeUpdate) ClearDir() *FieldTypeUpdate { return ftu } +// SetNdir sets the ndir field. +func (ftu *FieldTypeUpdate) SetNdir(h http.Dir) *FieldTypeUpdate { + ftu.mutation.SetNdir(h) + return ftu +} + +// SetNillableNdir sets the ndir field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableNdir(h *http.Dir) *FieldTypeUpdate { + if h != nil { + ftu.SetNdir(*h) + } + return ftu +} + +// ClearNdir clears the value of ndir. +func (ftu *FieldTypeUpdate) ClearNdir() *FieldTypeUpdate { + ftu.mutation.ClearNdir() + return ftu +} + +// SetStr sets the str field. +func (ftu *FieldTypeUpdate) SetStr(ss sql.NullString) *FieldTypeUpdate { + ftu.mutation.SetStr(ss) + return ftu +} + +// ClearStr clears the value of str. +func (ftu *FieldTypeUpdate) ClearStr() *FieldTypeUpdate { + ftu.mutation.ClearStr() + return ftu +} + +// SetNullStr sets the null_str field. +func (ftu *FieldTypeUpdate) SetNullStr(ss sql.NullString) *FieldTypeUpdate { + ftu.mutation.SetNullStr(ss) + return ftu +} + +// ClearNullStr clears the value of null_str. +func (ftu *FieldTypeUpdate) ClearNullStr() *FieldTypeUpdate { + ftu.mutation.ClearNullStr() + return ftu +} + +// SetLink sets the link field. +func (ftu *FieldTypeUpdate) SetLink(s schema.Link) *FieldTypeUpdate { + ftu.mutation.SetLink(s) + return ftu +} + +// ClearLink clears the value of link. +func (ftu *FieldTypeUpdate) ClearLink() *FieldTypeUpdate { + ftu.mutation.ClearLink() + return ftu +} + +// SetNullLink sets the null_link field. +func (ftu *FieldTypeUpdate) SetNullLink(s schema.Link) *FieldTypeUpdate { + ftu.mutation.SetNullLink(s) + return ftu +} + +// ClearNullLink clears the value of null_link. +func (ftu *FieldTypeUpdate) ClearNullLink() *FieldTypeUpdate { + ftu.mutation.ClearNullLink() + return ftu +} + // Save executes the query and returns the number of rows/vertices matched by this operation. func (ftu *FieldTypeUpdate) Save(ctx context.Context) (int, error) { if v, ok := ftu.mutation.ValidateOptionalInt32(); ok { @@ -906,6 +976,21 @@ func (ftu *FieldTypeUpdate) gremlin() *dsl.Traversal { if value, ok := ftu.mutation.Dir(); ok { v.Property(dsl.Single, fieldtype.FieldDir, value) } + if value, ok := ftu.mutation.Ndir(); ok { + v.Property(dsl.Single, fieldtype.FieldNdir, value) + } + if value, ok := ftu.mutation.Str(); ok { + v.Property(dsl.Single, fieldtype.FieldStr, value) + } + if value, ok := ftu.mutation.NullStr(); ok { + v.Property(dsl.Single, fieldtype.FieldNullStr, value) + } + if value, ok := ftu.mutation.Link(); ok { + v.Property(dsl.Single, fieldtype.FieldLink, value) + } + if value, ok := ftu.mutation.NullLink(); ok { + v.Property(dsl.Single, fieldtype.FieldNullLink, value) + } var properties []interface{} if ftu.mutation.OptionalIntCleared() { properties = append(properties, fieldtype.FieldOptionalInt) @@ -973,6 +1058,21 @@ func (ftu *FieldTypeUpdate) gremlin() *dsl.Traversal { if ftu.mutation.DirCleared() { properties = append(properties, fieldtype.FieldDir) } + if ftu.mutation.NdirCleared() { + properties = append(properties, fieldtype.FieldNdir) + } + if ftu.mutation.StrCleared() { + properties = append(properties, fieldtype.FieldStr) + } + if ftu.mutation.NullStrCleared() { + properties = append(properties, fieldtype.FieldNullStr) + } + if ftu.mutation.LinkCleared() { + properties = append(properties, fieldtype.FieldLink) + } + if ftu.mutation.NullLinkCleared() { + properties = append(properties, fieldtype.FieldNullLink) + } if len(properties) > 0 { v.SideEffect(__.Properties(properties...).Drop()) } @@ -1626,6 +1726,74 @@ func (ftuo *FieldTypeUpdateOne) ClearDir() *FieldTypeUpdateOne { return ftuo } +// SetNdir sets the ndir field. +func (ftuo *FieldTypeUpdateOne) SetNdir(h http.Dir) *FieldTypeUpdateOne { + ftuo.mutation.SetNdir(h) + return ftuo +} + +// SetNillableNdir sets the ndir field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableNdir(h *http.Dir) *FieldTypeUpdateOne { + if h != nil { + ftuo.SetNdir(*h) + } + return ftuo +} + +// ClearNdir clears the value of ndir. +func (ftuo *FieldTypeUpdateOne) ClearNdir() *FieldTypeUpdateOne { + ftuo.mutation.ClearNdir() + return ftuo +} + +// SetStr sets the str field. +func (ftuo *FieldTypeUpdateOne) SetStr(ss sql.NullString) *FieldTypeUpdateOne { + ftuo.mutation.SetStr(ss) + return ftuo +} + +// ClearStr clears the value of str. +func (ftuo *FieldTypeUpdateOne) ClearStr() *FieldTypeUpdateOne { + ftuo.mutation.ClearStr() + return ftuo +} + +// SetNullStr sets the null_str field. +func (ftuo *FieldTypeUpdateOne) SetNullStr(ss sql.NullString) *FieldTypeUpdateOne { + ftuo.mutation.SetNullStr(ss) + return ftuo +} + +// ClearNullStr clears the value of null_str. +func (ftuo *FieldTypeUpdateOne) ClearNullStr() *FieldTypeUpdateOne { + ftuo.mutation.ClearNullStr() + return ftuo +} + +// SetLink sets the link field. +func (ftuo *FieldTypeUpdateOne) SetLink(s schema.Link) *FieldTypeUpdateOne { + ftuo.mutation.SetLink(s) + return ftuo +} + +// ClearLink clears the value of link. +func (ftuo *FieldTypeUpdateOne) ClearLink() *FieldTypeUpdateOne { + ftuo.mutation.ClearLink() + return ftuo +} + +// SetNullLink sets the null_link field. +func (ftuo *FieldTypeUpdateOne) SetNullLink(s schema.Link) *FieldTypeUpdateOne { + ftuo.mutation.SetNullLink(s) + return ftuo +} + +// ClearNullLink clears the value of null_link. +func (ftuo *FieldTypeUpdateOne) ClearNullLink() *FieldTypeUpdateOne { + ftuo.mutation.ClearNullLink() + return ftuo +} + // Save executes the query and returns the updated entity. func (ftuo *FieldTypeUpdateOne) Save(ctx context.Context) (*FieldType, error) { if v, ok := ftuo.mutation.ValidateOptionalInt32(); ok { @@ -1865,6 +2033,21 @@ func (ftuo *FieldTypeUpdateOne) gremlin(id string) *dsl.Traversal { if value, ok := ftuo.mutation.Dir(); ok { v.Property(dsl.Single, fieldtype.FieldDir, value) } + if value, ok := ftuo.mutation.Ndir(); ok { + v.Property(dsl.Single, fieldtype.FieldNdir, value) + } + if value, ok := ftuo.mutation.Str(); ok { + v.Property(dsl.Single, fieldtype.FieldStr, value) + } + if value, ok := ftuo.mutation.NullStr(); ok { + v.Property(dsl.Single, fieldtype.FieldNullStr, value) + } + if value, ok := ftuo.mutation.Link(); ok { + v.Property(dsl.Single, fieldtype.FieldLink, value) + } + if value, ok := ftuo.mutation.NullLink(); ok { + v.Property(dsl.Single, fieldtype.FieldNullLink, value) + } var properties []interface{} if ftuo.mutation.OptionalIntCleared() { properties = append(properties, fieldtype.FieldOptionalInt) @@ -1932,6 +2115,21 @@ func (ftuo *FieldTypeUpdateOne) gremlin(id string) *dsl.Traversal { if ftuo.mutation.DirCleared() { properties = append(properties, fieldtype.FieldDir) } + if ftuo.mutation.NdirCleared() { + properties = append(properties, fieldtype.FieldNdir) + } + if ftuo.mutation.StrCleared() { + properties = append(properties, fieldtype.FieldStr) + } + if ftuo.mutation.NullStrCleared() { + properties = append(properties, fieldtype.FieldNullStr) + } + if ftuo.mutation.LinkCleared() { + properties = append(properties, fieldtype.FieldLink) + } + if ftuo.mutation.NullLinkCleared() { + properties = append(properties, fieldtype.FieldNullLink) + } if len(properties) > 0 { v.SideEffect(__.Properties(properties...).Drop()) } diff --git a/entc/integration/gremlin/ent/mutation.go b/entc/integration/gremlin/ent/mutation.go index 5df0e3589..e5e58c965 100644 --- a/entc/integration/gremlin/ent/mutation.go +++ b/entc/integration/gremlin/ent/mutation.go @@ -8,11 +8,13 @@ package ent import ( "context" + "database/sql" "fmt" "net/http" "sync" "time" + "github.com/facebookincubator/ent/entc/integration/ent/schema" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/card" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/comment" "github.com/facebookincubator/ent/entc/integration/gremlin/ent/fieldtype" @@ -1251,6 +1253,11 @@ type FieldTypeMutation struct { decimal *float64 adddecimal *float64 dir *http.Dir + ndir *http.Dir + str *sql.NullString + null_str *sql.NullString + link *schema.Link + null_link *schema.Link clearedFields map[string]struct{} done bool oldValue func(context.Context) (*FieldType, error) @@ -3119,6 +3126,256 @@ func (m *FieldTypeMutation) ResetDir() { delete(m.clearedFields, fieldtype.FieldDir) } +// SetNdir sets the ndir field. +func (m *FieldTypeMutation) SetNdir(h http.Dir) { + m.ndir = &h +} + +// Ndir returns the ndir value in the mutation. +func (m *FieldTypeMutation) Ndir() (r http.Dir, exists bool) { + v := m.ndir + if v == nil { + return + } + return *v, true +} + +// OldNdir returns the old ndir value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldNdir(ctx context.Context) (v *http.Dir, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldNdir is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldNdir requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNdir: %w", err) + } + return oldValue.Ndir, nil +} + +// ClearNdir clears the value of ndir. +func (m *FieldTypeMutation) ClearNdir() { + m.ndir = nil + m.clearedFields[fieldtype.FieldNdir] = struct{}{} +} + +// NdirCleared returns if the field ndir was cleared in this mutation. +func (m *FieldTypeMutation) NdirCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldNdir] + return ok +} + +// ResetNdir reset all changes of the "ndir" field. +func (m *FieldTypeMutation) ResetNdir() { + m.ndir = nil + delete(m.clearedFields, fieldtype.FieldNdir) +} + +// SetStr sets the str field. +func (m *FieldTypeMutation) SetStr(ss sql.NullString) { + m.str = &ss +} + +// Str returns the str value in the mutation. +func (m *FieldTypeMutation) Str() (r sql.NullString, exists bool) { + v := m.str + if v == nil { + return + } + return *v, true +} + +// OldStr returns the old str value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldStr(ctx context.Context) (v sql.NullString, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldStr is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldStr requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStr: %w", err) + } + return oldValue.Str, nil +} + +// ClearStr clears the value of str. +func (m *FieldTypeMutation) ClearStr() { + m.str = nil + m.clearedFields[fieldtype.FieldStr] = struct{}{} +} + +// StrCleared returns if the field str was cleared in this mutation. +func (m *FieldTypeMutation) StrCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldStr] + return ok +} + +// ResetStr reset all changes of the "str" field. +func (m *FieldTypeMutation) ResetStr() { + m.str = nil + delete(m.clearedFields, fieldtype.FieldStr) +} + +// SetNullStr sets the null_str field. +func (m *FieldTypeMutation) SetNullStr(ss sql.NullString) { + m.null_str = &ss +} + +// NullStr returns the null_str value in the mutation. +func (m *FieldTypeMutation) NullStr() (r sql.NullString, exists bool) { + v := m.null_str + if v == nil { + return + } + return *v, true +} + +// OldNullStr returns the old null_str value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldNullStr(ctx context.Context) (v *sql.NullString, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldNullStr is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldNullStr requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNullStr: %w", err) + } + return oldValue.NullStr, nil +} + +// ClearNullStr clears the value of null_str. +func (m *FieldTypeMutation) ClearNullStr() { + m.null_str = nil + m.clearedFields[fieldtype.FieldNullStr] = struct{}{} +} + +// NullStrCleared returns if the field null_str was cleared in this mutation. +func (m *FieldTypeMutation) NullStrCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldNullStr] + return ok +} + +// ResetNullStr reset all changes of the "null_str" field. +func (m *FieldTypeMutation) ResetNullStr() { + m.null_str = nil + delete(m.clearedFields, fieldtype.FieldNullStr) +} + +// SetLink sets the link field. +func (m *FieldTypeMutation) SetLink(s schema.Link) { + m.link = &s +} + +// Link returns the link value in the mutation. +func (m *FieldTypeMutation) Link() (r schema.Link, exists bool) { + v := m.link + if v == nil { + return + } + return *v, true +} + +// OldLink returns the old link value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldLink(ctx context.Context) (v schema.Link, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldLink is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLink: %w", err) + } + return oldValue.Link, nil +} + +// ClearLink clears the value of link. +func (m *FieldTypeMutation) ClearLink() { + m.link = nil + m.clearedFields[fieldtype.FieldLink] = struct{}{} +} + +// LinkCleared returns if the field link was cleared in this mutation. +func (m *FieldTypeMutation) LinkCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldLink] + return ok +} + +// ResetLink reset all changes of the "link" field. +func (m *FieldTypeMutation) ResetLink() { + m.link = nil + delete(m.clearedFields, fieldtype.FieldLink) +} + +// SetNullLink sets the null_link field. +func (m *FieldTypeMutation) SetNullLink(s schema.Link) { + m.null_link = &s +} + +// NullLink returns the null_link value in the mutation. +func (m *FieldTypeMutation) NullLink() (r schema.Link, exists bool) { + v := m.null_link + if v == nil { + return + } + return *v, true +} + +// OldNullLink returns the old null_link value of the FieldType. +// If the FieldType object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *FieldTypeMutation) OldNullLink(ctx context.Context) (v *schema.Link, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldNullLink is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldNullLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNullLink: %w", err) + } + return oldValue.NullLink, nil +} + +// ClearNullLink clears the value of null_link. +func (m *FieldTypeMutation) ClearNullLink() { + m.null_link = nil + m.clearedFields[fieldtype.FieldNullLink] = struct{}{} +} + +// NullLinkCleared returns if the field null_link was cleared in this mutation. +func (m *FieldTypeMutation) NullLinkCleared() bool { + _, ok := m.clearedFields[fieldtype.FieldNullLink] + return ok +} + +// ResetNullLink reset all changes of the "null_link" field. +func (m *FieldTypeMutation) ResetNullLink() { + m.null_link = nil + delete(m.clearedFields, fieldtype.FieldNullLink) +} + // Op returns the operation name. func (m *FieldTypeMutation) Op() Op { return m.op @@ -3133,7 +3390,7 @@ func (m *FieldTypeMutation) Type() string { // this mutation. Note that, in order to get all numeric // fields that were in/decremented, call AddedFields(). func (m *FieldTypeMutation) Fields() []string { - fields := make([]string, 0, 27) + fields := make([]string, 0, 32) if m.int != nil { fields = append(fields, fieldtype.FieldInt) } @@ -3215,6 +3472,21 @@ func (m *FieldTypeMutation) Fields() []string { if m.dir != nil { fields = append(fields, fieldtype.FieldDir) } + if m.ndir != nil { + fields = append(fields, fieldtype.FieldNdir) + } + if m.str != nil { + fields = append(fields, fieldtype.FieldStr) + } + if m.null_str != nil { + fields = append(fields, fieldtype.FieldNullStr) + } + if m.link != nil { + fields = append(fields, fieldtype.FieldLink) + } + if m.null_link != nil { + fields = append(fields, fieldtype.FieldNullLink) + } return fields } @@ -3277,6 +3549,16 @@ func (m *FieldTypeMutation) Field(name string) (ent.Value, bool) { return m.Decimal() case fieldtype.FieldDir: return m.Dir() + case fieldtype.FieldNdir: + return m.Ndir() + case fieldtype.FieldStr: + return m.Str() + case fieldtype.FieldNullStr: + return m.NullStr() + case fieldtype.FieldLink: + return m.Link() + case fieldtype.FieldNullLink: + return m.NullLink() } return nil, false } @@ -3340,6 +3622,16 @@ func (m *FieldTypeMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldDecimal(ctx) case fieldtype.FieldDir: return m.OldDir(ctx) + case fieldtype.FieldNdir: + return m.OldNdir(ctx) + case fieldtype.FieldStr: + return m.OldStr(ctx) + case fieldtype.FieldNullStr: + return m.OldNullStr(ctx) + case fieldtype.FieldLink: + return m.OldLink(ctx) + case fieldtype.FieldNullLink: + return m.OldNullLink(ctx) } return nil, fmt.Errorf("unknown FieldType field %s", name) } @@ -3538,6 +3830,41 @@ func (m *FieldTypeMutation) SetField(name string, value ent.Value) error { } m.SetDir(v) return nil + case fieldtype.FieldNdir: + v, ok := value.(http.Dir) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNdir(v) + return nil + case fieldtype.FieldStr: + v, ok := value.(sql.NullString) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStr(v) + return nil + case fieldtype.FieldNullStr: + v, ok := value.(sql.NullString) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNullStr(v) + return nil + case fieldtype.FieldLink: + v, ok := value.(schema.Link) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLink(v) + return nil + case fieldtype.FieldNullLink: + v, ok := value.(schema.Link) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNullLink(v) + return nil } return fmt.Errorf("unknown FieldType field %s", name) } @@ -3925,6 +4252,21 @@ func (m *FieldTypeMutation) ClearedFields() []string { if m.FieldCleared(fieldtype.FieldDir) { fields = append(fields, fieldtype.FieldDir) } + if m.FieldCleared(fieldtype.FieldNdir) { + fields = append(fields, fieldtype.FieldNdir) + } + if m.FieldCleared(fieldtype.FieldStr) { + fields = append(fields, fieldtype.FieldStr) + } + if m.FieldCleared(fieldtype.FieldNullStr) { + fields = append(fields, fieldtype.FieldNullStr) + } + if m.FieldCleared(fieldtype.FieldLink) { + fields = append(fields, fieldtype.FieldLink) + } + if m.FieldCleared(fieldtype.FieldNullLink) { + fields = append(fields, fieldtype.FieldNullLink) + } return fields } @@ -4005,6 +4347,21 @@ func (m *FieldTypeMutation) ClearField(name string) error { case fieldtype.FieldDir: m.ClearDir() return nil + case fieldtype.FieldNdir: + m.ClearNdir() + return nil + case fieldtype.FieldStr: + m.ClearStr() + return nil + case fieldtype.FieldNullStr: + m.ClearNullStr() + return nil + case fieldtype.FieldLink: + m.ClearLink() + return nil + case fieldtype.FieldNullLink: + m.ClearNullLink() + return nil } return fmt.Errorf("unknown FieldType nullable field %s", name) } @@ -4095,6 +4452,21 @@ func (m *FieldTypeMutation) ResetField(name string) error { case fieldtype.FieldDir: m.ResetDir() return nil + case fieldtype.FieldNdir: + m.ResetNdir() + return nil + case fieldtype.FieldStr: + m.ResetStr() + return nil + case fieldtype.FieldNullStr: + m.ResetNullStr() + return nil + case fieldtype.FieldLink: + m.ResetLink() + return nil + case fieldtype.FieldNullLink: + m.ResetNullLink() + return nil } return fmt.Errorf("unknown FieldType field %s", name) } diff --git a/entc/integration/type_test.go b/entc/integration/type_test.go index 064852264..4610a55c4 100644 --- a/entc/integration/type_test.go +++ b/entc/integration/type_test.go @@ -8,9 +8,14 @@ import ( "context" "math" "net/http" + "net/url" "testing" "time" + "github.com/facebookincubator/ent/entc/integration/ent/schema" + + "github.com/facebookincubator/ent/dialect/sql" + "github.com/facebookincubator/ent/entc/integration/ent" "github.com/stretchr/testify/require" @@ -20,6 +25,9 @@ func Types(t *testing.T, client *ent.Client) { ctx := context.Background() require := require.New(t) + link, err := url.Parse("localhost") + require.NoError(err) + ft := client.FieldType.Create(). SetInt(1). SetInt8(8). @@ -49,6 +57,12 @@ func Types(t *testing.T, client *ent.Client) { SetNillableInt16(math.MinInt16). SetNillableInt32(math.MinInt32). SetNillableInt64(math.MinInt64). + SetDir("dir"). + SetNdir("ndir"). + SetStr(sql.NullString{String: "str", Valid: true}). + SetNullStr(sql.NullString{String: "str", Valid: true}). + SetLink(schema.Link{URL: link}). + SetNullLink(schema.Link{URL: link}). SaveX(ctx) require.Equal(int8(math.MinInt8), ft.OptionalInt8) @@ -59,6 +73,13 @@ func Types(t *testing.T, client *ent.Client) { require.Equal(int16(math.MinInt16), *ft.NillableInt16) require.Equal(int32(math.MinInt32), *ft.NillableInt32) require.Equal(int64(math.MinInt64), *ft.NillableInt64) + require.Equal(http.Dir("dir"), ft.Dir) + require.NotNil(*ft.Ndir) + require.Equal(http.Dir("ndir"), *ft.Ndir) + require.Equal("str", ft.Str.String) + require.Equal("str", ft.NullStr.String) + require.Equal("localhost", ft.Link.String()) + require.Equal("localhost", ft.NullLink.String()) ft = ft.Update(). SetInt(1). @@ -78,6 +99,10 @@ func Types(t *testing.T, client *ent.Client) { SetDecimal(10.20). SetDir("dir"). SetNdir("ndir"). + SetStr(sql.NullString{String: "str", Valid: true}). + SetNullStr(sql.NullString{String: "str", Valid: true}). + SetLink(schema.Link{URL: link}). + SetNullLink(schema.Link{URL: link}). SaveX(ctx) require.Equal(int8(math.MaxInt8), ft.OptionalInt8) @@ -89,8 +114,12 @@ func Types(t *testing.T, client *ent.Client) { require.Equal(int32(math.MaxInt32), *ft.NillableInt32) require.Equal(int64(math.MaxInt64), *ft.NillableInt64) require.Equal(10.20, ft.Decimal) + require.False(ft.Datetime.IsZero()) require.Equal(http.Dir("dir"), ft.Dir) require.NotNil(*ft.Ndir) require.Equal(http.Dir("ndir"), *ft.Ndir) - require.False(ft.Datetime.IsZero()) + require.Equal("str", ft.Str.String) + require.Equal("str", ft.NullStr.String) + require.Equal("localhost", ft.Link.String()) + require.Equal("localhost", ft.NullLink.String()) } diff --git a/schema/field/field.go b/schema/field/field.go index 0d02ca914..f54cb41d2 100644 --- a/schema/field/field.go +++ b/schema/field/field.go @@ -714,7 +714,7 @@ func (d *Descriptor) goType(typ interface{}, expectKind reflect.Kind) { tv := indirect(t) info := &TypeInfo{ Type: TypeString, - Ident: t.String(), + Ident: tv.String(), PkgPath: tv.PkgPath(), RType: &RType{ Name: tv.Name(), diff --git a/schema/field/field_test.go b/schema/field/field_test.go index 4ee405491..2977655a1 100644 --- a/schema/field/field_test.go +++ b/schema/field/field_test.go @@ -122,9 +122,9 @@ func TestString(t *testing.T) { 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, "sql.NullString", fd.Info.Ident) assert.Equal(t, "database/sql", fd.Info.PkgPath) - assert.Equal(t, "*sql.NullString", fd.Info.String()) + 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()) @@ -136,9 +136,9 @@ func TestString(t *testing.T) { *url.URL } fd = field.String("nullable_url").GoType(&tURL{}).Descriptor() - assert.Equal(t, "*field_test.tURL", fd.Info.Ident) + 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.Equal(t, "field_test.tURL", fd.Info.String()) assert.True(t, fd.Info.ValueScanner()) assert.True(t, fd.Info.Stringer())