diff --git a/dialect/sql/schema/mysql_test.go b/dialect/sql/schema/mysql_test.go index 07ab787e4..8efe634ce 100644 --- a/dialect/sql/schema/mysql_test.go +++ b/dialect/sql/schema/mysql_test.go @@ -55,6 +55,7 @@ func TestMySQL_Create(t *testing.T) { {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "age", Type: field.TypeInt}, {Name: "doc", Type: field.TypeJSON, Nullable: true}, + {Name: "enums", Type: field.TypeEnum, Enums: []string{"a", "b"}}, }, }, }, @@ -65,7 +66,7 @@ func TestMySQL_Create(t *testing.T) { mock.ExpectQuery(escape("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_SCHEMA` = (SELECT DATABASE()) AND `TABLE_NAME` = ?")). WithArgs("users"). WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(0)) - mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `users`(`id` bigint AUTO_INCREMENT NOT NULL, `name` varchar(255) NULL, `age` bigint NOT NULL, `doc` json NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4")). + mock.ExpectExec(escape("CREATE TABLE IF NOT EXISTS `users`(`id` bigint AUTO_INCREMENT NOT NULL, `name` varchar(255) NULL, `age` bigint NOT NULL, `doc` json NULL, `enums` enum('a', 'b') NOT NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4")). WillReturnResult(sqlmock.NewResult(0, 1)) mock.ExpectCommit() }, @@ -183,8 +184,8 @@ func TestMySQL_Create(t *testing.T) { WithArgs("users"). WillReturnRows(sqlmock.NewRows([]string{"column_name", "column_type", "is_nullable", "column_key", "column_default", "extra", "character_set_name", "collation_name"}). AddRow("id", "bigint(20)", "NO", "PRI", "NULL", "auto_increment", "", ""). - AddRow("name", "varchar(255)", "NO", "YES", "NULL", "", "", ""). - AddRow("text", "longtext", "NO", "YES", "NULL", "", "", "")) + AddRow("name", "varchar(255)", "YES", "YES", "NULL", "", "", ""). + AddRow("text", "longtext", "YES", "YES", "NULL", "", "", "")) mock.ExpectQuery(escape("SELECT `index_name`, `column_name`, `non_unique`, `seq_in_index` FROM INFORMATION_SCHEMA.STATISTICS WHERE `TABLE_SCHEMA` = (SELECT DATABASE()) AND `TABLE_NAME` = ?")). WithArgs("users"). WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "non_unique", "seq_in_index"}). @@ -194,6 +195,47 @@ func TestMySQL_Create(t *testing.T) { mock.ExpectCommit() }, }, + { + name: "enums", + tables: []*Table{ + { + Name: "users", + Columns: []*Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "name", Type: field.TypeString, Nullable: true}, + {Name: "enums1", Type: field.TypeEnum, Enums: []string{"a", "b"}}, // add enum. + {Name: "enums2", Type: field.TypeEnum, Enums: []string{"a"}}, // remove enum. + {Name: "enums3", Type: field.TypeEnum, Enums: []string{"a", "b"}}, // order does not effect. + }, + PrimaryKey: []*Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + }, + }, + }, + before: func(mock sqlmock.Sqlmock) { + mock.ExpectBegin() + mock.ExpectQuery(escape("SHOW VARIABLES LIKE 'version'")). + WillReturnRows(sqlmock.NewRows([]string{"Variable_name", "Value"}).AddRow("version", "5.7.23")) + mock.ExpectQuery(escape("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE `TABLE_SCHEMA` = (SELECT DATABASE()) AND `TABLE_NAME` = ?")). + WithArgs("users"). + WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(1)) + mock.ExpectQuery(escape("SELECT `column_name`, `column_type`, `is_nullable`, `column_key`, `column_default`, `extra`, `character_set_name`, `collation_name` FROM INFORMATION_SCHEMA.COLUMNS WHERE `TABLE_SCHEMA` = (SELECT DATABASE()) AND `TABLE_NAME` = ?")). + WithArgs("users"). + WillReturnRows(sqlmock.NewRows([]string{"column_name", "column_type", "is_nullable", "column_key", "column_default", "extra", "character_set_name", "collation_name"}). + AddRow("id", "bigint(20)", "NO", "PRI", "NULL", "auto_increment", "", ""). + AddRow("name", "varchar(255)", "YES", "YES", "NULL", "", "", ""). + AddRow("enums1", "enum('a')", "YES", "NO", "NULL", "", "", ""). + AddRow("enums2", "enum('b', 'a')", "NO", "YES", "NULL", "", "", ""). + AddRow("enums3", "enum('b', 'a')", "NO", "YES", "NULL", "", "", "")) + mock.ExpectQuery(escape("SELECT `index_name`, `column_name`, `non_unique`, `seq_in_index` FROM INFORMATION_SCHEMA.STATISTICS WHERE `TABLE_SCHEMA` = (SELECT DATABASE()) AND `TABLE_NAME` = ?")). + WithArgs("users"). + WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "non_unique", "seq_in_index"}). + AddRow("PRIMARY", "id", "0", "1")) + mock.ExpectExec(escape("ALTER TABLE `users` MODIFY COLUMN `enums1` enum('a', 'b') NOT NULL, MODIFY COLUMN `enums2` enum('a') NOT NULL")). + WillReturnResult(sqlmock.NewResult(0, 1)) + mock.ExpectCommit() + }, + }, { name: "datetime and timestamp", tables: []*Table{ diff --git a/dialect/sql/schema/schema.go b/dialect/sql/schema/schema.go index 8cb30e9f6..881ebe533 100644 --- a/dialect/sql/schema/schema.go +++ b/dialect/sql/schema/schema.go @@ -7,6 +7,7 @@ package schema import ( "fmt" "math" + "sort" "strconv" "strings" @@ -182,6 +183,7 @@ type Column struct { Nullable bool // null or not null attribute. Default interface{} // default value. indexes Indexes // linked indexes. + Enums []string // enum values. } // UniqueKey returns boolean indicates if this column is a unique key. @@ -275,6 +277,13 @@ func (c *Column) MySQLType(version string) (t string) { // in MySQL timestamp columns are `NOT NULL by default, and assigning NULL // assigns the current_timestamp(). We avoid this if not set otherwise. c.Nullable = true + case field.TypeEnum: + values := make([]string, len(c.Enums)) + for i, e := range c.Enums { + values[i] = fmt.Sprintf("'%s'", e) + } + sort.Strings(values) + t = fmt.Sprintf("enum(%s)", strings.Join(values, ", ")) default: panic(fmt.Sprintf("unsupported type %q for column %q", c.Type.String(), c.Name)) } @@ -292,7 +301,7 @@ func (c *Column) SQLiteType() (t string) { t = "bigint" case field.TypeBytes: t = "blob" - case field.TypeString: + case field.TypeString, field.TypeEnum: size := c.Size if size == 0 { size = DefaultStringLen @@ -325,7 +334,7 @@ func (c *Column) ScanMySQL(rows *sql.Rows) error { c.Nullable = nullable.String == "YES" } switch parts := strings.FieldsFunc(c.typ, func(r rune) bool { - return r == '(' || r == ')' || r == ' ' + return r == '(' || r == ')' || r == ' ' || r == ',' }); parts[0] { case "int": c.Type = field.TypeInt32 @@ -380,6 +389,12 @@ func (c *Column) ScanMySQL(rows *sql.Rows) error { c.Type = field.TypeString case "json": c.Type = field.TypeJSON + case "enum": + c.Type = field.TypeEnum + c.Enums = make([]string, len(parts)-1) + for i, e := range parts[1:] { + c.Enums[i] = strings.Trim(e, "'") + } } if defaults.Valid && defaults.String != Null { return c.ScanDefault(defaults.String) diff --git a/entc/gen/func.go b/entc/gen/func.go index 2657f2b15..8cf99ae9d 100644 --- a/entc/gen/func.go +++ b/entc/gen/func.go @@ -46,6 +46,7 @@ var ( "hasField": hasField, "indirect": indirect, "hasSuffix": strings.HasSuffix, + "trimPackage": trimPackage, "xtemplate": xtemplate, "hasTemplate": hasTemplate, } @@ -61,6 +62,8 @@ func ops(f *Field) (op []Op) { op = boolOps case t == field.TypeString && strings.ToLower(f.Name) != "id": op = stringOps + case t == field.TypeEnum: + op = enumOps default: op = numericOps } @@ -284,6 +287,11 @@ func hasField(v interface{}, name string) bool { return vr.FieldByName(name).IsValid() } +// trimPackage trims the package name from the given identifier. +func trimPackage(ident, pkg string) string { + return strings.TrimPrefix(ident, pkg+".") +} + // indirect returns the item at the end of indirection. func indirect(v reflect.Value) reflect.Value { for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() { diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index d28bb3eaf..20ca01887 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -139,7 +139,7 @@ func templateBaseTmpl() (*asset, error) { return a, nil } -var _templateBuilderCreateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x56\x5d\x6f\xdb\x36\x14\x7d\x96\x7e\xc5\xad\xa0\x0e\x96\x91\xc8\x6d\xdf\xe6\x21\x03\xba\x34\x05\x02\x0c\xd9\x80\x64\x43\x81\x75\x18\x18\xea\xca\xe6\x42\x93\x2a\x49\x39\x09\x04\xfd\xf7\x81\x1f\x92\x28\xe7\x03\xee\x9e\x2c\x53\xe4\xb9\x87\xe7\x1c\x5d\xb2\xeb\x56\xcb\xf4\x5c\x36\x8f\x8a\x6d\xb6\x06\x3e\xbc\x7b\xff\xe3\x69\xa3\x50\xa3\x30\xf0\x99\x50\xbc\x95\xf2\x0e\x2e\x05\x2d\xe1\x23\xe7\xe0\x26\x69\xb0\xef\xd5\x1e\xab\x32\xbd\xd9\x32\x0d\x5a\xb6\x8a\x22\x50\x59\x21\x30\x0d\x9c\x51\x14\x1a\x2b\x68\x45\x85\x0a\xcc\x16\xe1\x63\x43\xe8\x16\xe1\x43\xf9\x6e\x78\x0b\xb5\x6c\x45\x95\x32\xe1\xde\xff\x7a\x79\x7e\x71\x75\x7d\x01\x35\xe3\x08\x61\x4c\x49\x69\xa0\x62\x0a\xa9\x91\xea\x11\x64\x0d\x26\x2a\x66\x14\x62\x99\x2e\x57\x7d\x9f\xa6\x5d\x07\x15\xd6\x4c\x20\x64\x54\x21\x31\x98\x41\xdf\xdb\xd1\xbc\xb9\xdb\xc0\xfa\x0c\x6e\x89\x46\xc8\xcb\x73\x29\x6a\xb6\x29\x7f\x27\xf4\x8e\x6c\x10\xc2\x52\x83\xbb\x86\x13\x83\x90\x6d\x91\x54\xa8\x32\xc8\x9f\xbe\x62\xbb\x46\x2a\x13\xbd\xca\x6f\x5b\xc6\xed\xf6\xd6\x67\xd0\x28\x26\x0c\x2c\x1a\xa2\x29\xe1\x90\x97\x57\x64\x87\x05\x64\xe7\x73\x2e\x0a\x29\xb2\xbd\x5f\x31\x3e\x8f\x30\x16\x76\xb5\x82\x18\xb9\xef\xad\x9a\x56\x8a\x61\xa4\x96\x0a\xdc\x0e\x99\xd8\x00\x71\x93\x5d\x31\x3b\x15\x85\x61\xe6\xb1\x4c\xcd\x63\x83\x87\x30\xda\xa8\x96\x1a\xe8\xd2\x84\x3a\x09\xd2\xa4\xeb\x40\x11\xb1\x41\xc8\xff\x39\x81\xbc\xb6\x9c\xf2\xf2\x33\x43\x5e\x69\x4b\x25\x49\xba\xee\x14\xf2\xba\xbc\x76\x2b\xdd\x0b\x0b\xb4\xb4\xc0\x75\x79\x63\x6b\xd8\x69\x5d\x07\x28\xaa\xf0\x78\x1a\x43\xa2\x87\xbc\xa8\x36\x18\x23\xe2\x21\xe2\x8e\x34\x7f\xb9\x7d\x5c\x7e\x1a\x60\xff\xf6\x74\xbb\x09\xff\xb4\xef\x53\x2f\xfb\x3d\x33\x5b\xc0\x07\x63\x47\x73\xc8\x7e\xf1\x7b\xcc\x66\x3a\x26\x33\xe7\x34\x1a\x63\x67\x94\xc1\x87\xc0\xd7\x8a\x7d\x4d\xf6\xe8\xf5\x44\xaf\xf3\x4c\xd0\x10\xc3\x8a\x18\x62\xf3\x53\xa6\x75\x2b\x28\x2c\x66\x56\x0e\x92\x4c\xd5\x0b\x87\xba\xa0\xe6\x01\xa8\x14\x06\x1f\x8c\x8d\x9d\xfd\x2d\x60\xb1\x8c\x0b\x9c\x00\x2a\x25\x55\x61\x6d\x79\xcd\x8e\xd3\x51\x3d\x56\x83\x54\x56\xff\x4f\x58\x93\x96\x1b\x58\x08\x69\xec\xff\xdf\x1a\xc3\xa4\x20\xbc\x08\x93\x13\x56\xc3\x01\xcf\xd2\x3b\x77\xa0\xfe\xd9\x19\x08\xc6\x2d\x83\xc4\x96\xb0\x15\x22\xf8\x00\x96\x24\x7b\x4b\xc8\x71\x9f\xbe\x9d\x00\x18\xe6\x86\x3d\x8d\x10\x97\xfa\x86\xb9\x91\x45\x11\x65\x24\x54\x39\x82\x17\xfc\xb0\x1f\x38\x21\xd7\x38\x51\x51\x68\x5a\x25\x2c\xeb\xa0\x9f\x2e\xaf\xf0\x7e\x91\x0d\x5f\x7b\xdf\xaf\x61\xc7\xb4\xb6\x5f\x88\xc2\x6f\x2d\x53\x58\x41\xed\x70\xbf\x66\xbe\x56\xe0\xfa\x35\xcb\x8a\xb1\x46\x08\x59\x92\x24\x5e\xec\x68\x64\x48\x5d\x5e\x97\x7f\x12\xce\x2a\x62\xa4\x1a\x5c\x49\x6c\xfb\x04\x52\x55\x20\x5a\xce\xc9\x2d\x47\xa0\x5b\xa4\x77\x20\x05\x7f\x74\x9f\xab\x0c\xd6\x78\x0e\xda\x41\xc9\xd6\xd8\x86\xe5\x34\xde\x13\xde\x22\x2c\x57\x13\x20\xe4\x23\xd6\xfa\x0c\x88\x0d\xfa\xe4\xf0\x68\x79\xd0\xbd\x98\xd6\xb9\x7c\x4c\x6b\x6d\x82\x8f\x4c\xc1\x9b\x90\x02\x98\x2b\x61\x53\x84\x4a\xbd\xec\xfd\x28\x87\xf5\x79\x79\x4c\xa9\xe2\x27\x87\xf8\x26\x8e\xdd\xcc\xd2\x7a\x67\xca\x0b\x6b\x6b\x3d\xb7\x74\x3f\x96\xaa\x09\xe3\xd6\x52\xfb\xf8\xbc\xad\x6b\x78\xbb\xcf\x5c\x3a\xbc\xbf\x2f\xea\xd3\x43\x9c\xcd\x78\xf3\xf3\xe7\x23\x1a\x9b\x85\xc6\xf2\x0f\xc1\xbe\xb5\x18\x7d\x84\x1c\xc5\x61\xc3\x70\xba\x1c\xb6\xc1\x02\x7e\x86\xf7\x41\x8f\xa3\x12\xde\x72\xc3\x1a\x8e\x40\xb4\x66\x1b\xb1\x43\x61\x34\x48\x01\x04\x5a\x4f\x01\xab\x0d\x06\x65\xf0\x30\xf0\xcf\x24\xdc\x6d\xc0\x25\x0b\xa7\xa8\xbd\xde\x4b\x9e\x74\xf2\x59\x2f\xf9\x5f\x9f\xe9\xf7\x90\x3e\x74\x88\xd5\xb0\x31\xb0\xe0\x28\x20\x2f\xaf\x8d\x54\x64\x83\x05\xbc\x0f\x9b\xd0\xf7\xcc\xd0\xed\x93\x7d\x54\xca\x3e\x95\x9f\x18\xe1\x48\xcd\xc2\xb5\xe2\x43\xbf\xb5\xc7\xf2\xae\x07\x60\xef\x3b\xb5\xb7\x8a\xae\x83\x7f\x25\x13\xe3\xbc\x01\x4c\x43\x76\x02\xf6\xec\x5f\xa7\x93\x1c\xcf\xe9\xa8\x47\xc8\xe1\xe0\x28\x02\x89\x31\x99\xa1\x57\xc4\x48\xaf\x0a\xdb\x0a\xdd\x36\xf6\xbe\x82\x15\x54\x9e\x8e\x13\x31\x48\x15\x35\xd4\x97\x79\x31\x51\xe1\x43\xb4\xe3\x77\x73\x82\x11\xbf\xe9\x2c\xfd\x02\x94\x70\xae\xfd\xb9\x6a\x1b\x57\x43\x04\xa3\xda\x7a\xe3\x86\x7c\x35\x0d\x44\x78\xea\xdf\x75\xa4\x7e\x79\xfe\x4c\x9d\x1d\xa9\xd6\xbf\xfd\x49\xdc\xb4\xe2\x5d\x45\xf4\x43\x67\x8b\xfa\x90\xa3\xba\xf0\x3d\xa3\x4f\x07\x61\xf6\xfe\xda\x71\x5c\x20\x8e\xbd\x9e\xb8\x1e\x6f\x76\x0d\x1f\xef\x8e\x35\x64\xc1\xa7\xd5\x5b\xbd\x1a\xee\xb0\x51\x34\xfc\xa2\x87\xf1\x56\xe3\x97\x97\x07\x77\xb0\xe8\x76\x33\x3d\xfe\x17\x00\x00\xff\xff\xac\x39\x6a\xa9\xe1\x0b\x00\x00") +var _templateBuilderCreateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x56\x5d\x6f\xdb\x36\x14\x7d\x96\x7e\xc5\xad\xa0\x0e\x96\x91\xc8\x6d\xdf\xe6\x21\x03\xba\x34\x05\x02\x0c\xd9\x80\x64\x43\x81\x75\x18\x18\xea\xca\xe6\x42\x93\x2a\x49\x39\x09\x04\xfd\xf7\x81\x1f\x92\x28\xe7\x03\xee\x9e\x2c\x53\xe4\xb9\x87\xe7\x1c\x5d\xb2\xeb\x56\xcb\xf4\x5c\x36\x8f\x8a\x6d\xb6\x06\x3e\xbc\x7b\xff\xe3\x69\xa3\x50\xa3\x30\xf0\x99\x50\xbc\x95\xf2\x0e\x2e\x05\x2d\xe1\x23\xe7\xe0\x26\x69\xb0\xef\xd5\x1e\xab\x32\xbd\xd9\x32\x0d\x5a\xb6\x8a\x22\x50\x59\x21\x30\x0d\x9c\x51\x14\x1a\x2b\x68\x45\x85\x0a\xcc\x16\xe1\x63\x43\xe8\x16\xe1\x43\xf9\x6e\x78\x0b\xb5\x6c\x45\x95\x32\xe1\xde\xff\x7a\x79\x7e\x71\x75\x7d\x01\x35\xe3\x08\x61\x4c\x49\x69\xa0\x62\x0a\xa9\x91\xea\x11\x64\x0d\x26\x2a\x66\x14\x62\x99\x2e\x57\x7d\x9f\xa6\x5d\x07\x15\xd6\x4c\x20\x64\x54\x21\x31\x98\x41\xdf\xdb\xd1\xbc\xb9\xdb\xc0\xfa\x0c\x6e\x89\x46\xc8\xcb\x73\x29\x6a\xb6\x29\x7f\x27\xf4\x8e\x6c\x10\xc2\x52\x83\xbb\x86\x13\x83\x90\x6d\x91\x54\xa8\x32\xc8\x9f\xbe\x62\xbb\x46\x2a\x13\xbd\xca\x6f\x5b\xc6\xed\xf6\xd6\x67\xd0\x28\x26\x0c\x2c\x1a\xa2\x29\xe1\x90\x97\x57\x64\x87\x05\x64\xe7\x73\x2e\x0a\x29\xb2\xbd\x5f\x31\x3e\x8f\x30\x16\x76\xb5\x82\x18\xb9\xef\xad\x9a\x56\x8a\x61\xa4\x96\x0a\xdc\x0e\x99\xd8\x00\x71\x93\x5d\x31\x3b\x15\x85\x61\xe6\xb1\x4c\xcd\x63\x83\x87\x30\xda\xa8\x96\x1a\xe8\xd2\x84\x3a\x09\xd2\xa4\xeb\x40\x11\xb1\x41\xc8\xff\x39\x81\xbc\xb6\x9c\xf2\xf2\x33\x43\x5e\x69\x4b\x25\x49\xba\xee\x14\xf2\xba\xbc\x76\x2b\xdd\x0b\x0b\xb4\xb4\xc0\x75\x79\x63\x6b\xd8\x69\x5d\x07\x28\xaa\xf0\x78\x1a\x43\xa2\x87\xbc\xa8\x36\x18\x23\xe2\x21\xe2\x8e\x34\x7f\xb9\x7d\x5c\x7e\x1a\x60\xff\xf6\x74\xbb\x09\xff\xb4\xef\x53\x2f\xfb\x3d\x33\x5b\xc0\x07\x63\x47\x73\xc8\x7e\xf1\x7b\xcc\x66\x3a\x26\x33\xe7\x34\x1a\x63\x67\x94\xc1\x87\xc0\xd7\x8a\x7d\x4d\xf6\xe8\xf5\x44\xaf\xf3\x4c\xd0\x10\xc3\x8a\x18\x62\xf3\x53\xa6\x75\x2b\x28\x2c\x66\x56\x0e\x92\x4c\xd5\x0b\x87\xba\xa0\xe6\x01\xa8\x14\x06\x1f\x8c\x8d\x9d\xfd\x2d\x60\xb1\x8c\x0b\x9c\x00\x2a\x25\x55\x61\x6d\x79\xcd\x8e\xd3\x51\x3d\x56\x83\x54\x56\xff\x4f\x58\x93\x96\x1b\x58\x08\x69\xec\xff\xdf\x1a\xc3\xa4\x20\xbc\x08\x93\x13\x56\xc3\x01\xcf\xd2\x3b\x77\xa0\xfe\xd9\x19\x08\xc6\x2d\x83\xc4\x96\xb0\x15\x22\xf8\x00\x96\x24\x7b\x4b\xc8\x71\x9f\xbe\x9d\x00\x18\xe6\x86\x3d\x8d\x10\x97\xfa\x86\xb9\x91\x45\x11\x65\x24\x54\x39\x82\x17\xfc\xb0\x1f\x38\x21\xd7\x38\x51\x51\x68\x5a\x25\x2c\xeb\xa0\x9f\x2e\xaf\xf0\x7e\x91\x0d\x5f\x7b\xdf\xaf\x61\xc7\xb4\xb6\x5f\x88\xc2\x6f\x2d\x53\x58\x41\xed\x70\xbf\x66\xbe\x56\xe0\xfa\x35\xcb\x8a\xb1\x46\x08\x59\x92\x24\x5e\xec\x68\x64\x48\x9d\x97\xfe\x4f\xc2\x59\x45\x8c\x54\xda\x6f\xf3\x42\xb4\xbb\x61\xa9\xed\xa5\x40\xaa\x0a\x44\xcb\x39\xb9\xe5\x08\x74\x8b\xf4\x0e\xa4\xe0\x8f\xee\xdb\x95\xc1\x27\x4f\x48\x3b\x5c\xd9\x1a\xdb\xbd\x9c\xe0\x7b\xc2\x5b\x84\xe5\x6a\x02\x84\x7c\xc4\x5a\x9f\x01\xb1\xa9\x9f\xec\x1e\xfd\x0f\x26\x14\xd3\x3a\x17\x96\x69\xad\x8d\xf3\x91\x91\x78\x13\x22\x01\x73\x59\x6c\xa4\x50\xa9\x97\x83\x30\x0a\x63\x4d\x5f\x1e\x53\xaa\xf8\xc9\x21\xbe\x89\x33\x38\xf3\xb7\xde\x99\xf2\xc2\x7a\x5c\xcf\xfd\xdd\x8f\xa5\x6a\xc2\xb8\xf5\xd7\x3e\x3e\xef\xf1\x1a\xde\xee\x33\x17\x15\x6f\xf6\x8b\xfa\xf4\x10\x07\x35\xde\xfc\xfc\xf9\x88\x2e\x67\xa1\xb1\xfc\x43\xb0\x6f\x2d\x46\x5f\x24\x47\x71\xd8\x3d\x9c\x2e\x87\x3d\xb1\x80\x9f\xe1\x7d\xd0\xe3\xa8\xb8\xb7\xdc\xb0\x86\x23\x10\xad\xd9\x46\xec\x50\x18\x0d\x52\x00\x81\xd6\x53\xc0\x6a\x83\x41\x19\x3c\x4c\xff\x33\x71\x77\x1b\x70\xc9\xc2\x29\x6a\xaf\x37\x96\x27\x6d\x7d\xd6\x58\xfe\xd7\x37\xfb\x3d\xa4\x0f\x1d\x62\x35\x6c\x0c\x2c\x38\x0a\xc8\xcb\x6b\x23\x15\xd9\x60\x01\xef\xc3\x26\xf4\x3d\x33\x74\xfb\x64\x1f\x95\xb2\x4f\xe5\x27\x46\x38\x52\xb3\x70\x7d\xf9\xd0\x6f\xed\xb1\xbc\xeb\x01\xd8\xfb\x4e\xed\x15\xa3\xeb\xe0\x5f\xc9\xc4\x38\x6f\x00\xd3\x90\x9d\x80\xbd\x08\xac\xd3\x49\x8e\xe7\x74\xd4\x23\xe4\x70\x8a\x14\x81\xc4\x98\xcc\xd0\x2b\x62\xa4\x57\x85\x6d\x85\x6e\x1b\x7b\x79\xc1\x0a\x2a\x4f\xc7\x89\x18\xa4\x8a\xba\xeb\xcb\xbc\x98\xa8\xf0\x21\xda\xf1\xbb\x39\xc1\x88\xdf\x74\xb0\x7e\x01\x4a\x38\xd7\xfe\x90\xb5\x8d\xab\x21\x82\x51\x6d\xbd\x71\x43\xbe\x9a\x06\x22\x3c\xf5\xef\x3a\x5f\xbf\x3c\x7f\xc0\xce\xce\x57\xeb\xdf\xfe\x24\x6e\x5a\xf1\xae\x22\xfa\xa1\xb3\x45\x7d\xc8\x51\x5d\xf8\x9e\xd1\xa7\x83\x30\x7b\x7f\x07\x39\x2e\x10\xc7\xde\x55\x5c\x8f\x37\xbb\x86\x8f\x17\xc9\x1a\xb2\xe0\xd3\xea\xad\x5e\x0d\x17\xda\x28\x1a\x7e\xd1\xc3\x78\xc5\xf1\xcb\xcb\x83\x0b\x59\x74\xd5\x99\x1e\xff\x0b\x00\x00\xff\xff\x83\xbc\xd5\x3d\xee\x0b\x00\x00") func templateBuilderCreateTmplBytes() ([]byte, error) { return bindataRead( @@ -154,7 +154,7 @@ func templateBuilderCreateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/create.tmpl", size: 3041, mode: os.FileMode(420), modTime: time.Unix(1567330666, 0)} + info := bindataFileInfo{name: "template/builder/create.tmpl", size: 3054, mode: os.FileMode(420), modTime: time.Unix(1570030748, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -219,7 +219,7 @@ func templateBuilderSetterTmpl() (*asset, error) { return a, nil } -var _templateBuilderUpdateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xdc\x59\x6d\x6f\xe3\x36\xf2\x7f\x2d\x7d\x8a\xa9\xe0\x0d\xec\x20\x96\xb3\xfb\xee\x9f\x3f\x7c\x40\xbb\xc9\x02\x01\x0e\xdb\xc3\x66\xdb\x2b\x2e\x0d\x0a\x5a\x1c\xd9\x6c\x64\x4a\x4b\x52\x4e\x72\x3e\x7d\xf7\x03\x9f\x64\x4a\x96\x9d\xa4\x08\x70\x68\x5f\xc5\xe2\xc3\x70\xe6\x37\xbf\x79\x20\xb3\xdd\xce\x4e\xe3\x8f\x65\xf5\x24\xd8\x72\xa5\xe0\xc3\xf9\xfb\xff\x9b\x56\x02\x25\x72\x05\x9f\x48\x86\x8b\xb2\xbc\x87\x6b\x9e\xa5\xf0\x7d\x51\x80\x59\x24\x41\xcf\x8b\x0d\xd2\x34\xfe\xba\x62\x12\x64\x59\x8b\x0c\x21\x2b\x29\x02\x93\x50\xb0\x0c\xb9\x44\x0a\x35\xa7\x28\x40\xad\x10\xbe\xaf\x48\xb6\x42\xf8\x90\x9e\xfb\x59\xc8\xcb\x9a\xd3\x98\x71\x33\xff\xf7\xeb\x8f\x57\x9f\x6f\xae\x20\x67\x05\x82\x1b\x13\x65\xa9\x80\x32\x81\x99\x2a\xc5\x13\x94\x39\xa8\xe0\x30\x25\x10\xd3\xf8\x74\xd6\x34\x71\xbc\xdd\x02\xc5\x9c\x71\x84\xa4\xae\x28\x51\x98\x40\xd3\xe8\xd1\x51\x75\xbf\x84\x8b\x39\x2c\x88\x44\x18\xa5\x1f\x4b\x9e\xb3\x65\xfa\x0f\x92\xdd\x93\x25\x82\xdb\xaa\x70\x5d\x15\x44\x21\x24\x2b\x24\x14\x45\x02\xa3\xfd\x29\xb6\xae\x4a\xa1\x82\xa9\xd1\xa2\x66\x85\x36\xef\x62\x0e\x95\x60\x5c\xc1\xb8\x22\x32\x23\x05\x8c\xd2\xcf\x64\x8d\x13\x48\x7e\xea\xea\x22\x30\x43\xb6\xb1\x3b\xda\xdf\xad\x18\xb7\x68\x5d\x17\x8a\x49\x55\x0a\xad\xe0\xc5\x1c\x96\x0a\xc6\x05\x72\x18\xa5\x37\x76\x70\x02\xef\x8d\x0a\xb3\x19\x84\x5a\x34\x8d\x46\x5e\xc3\xe6\x47\xf2\x52\x80\x41\x83\xf1\xa5\x59\x6a\xd4\xd2\x0b\x91\x2b\xa6\x18\xca\x34\x56\x4f\x15\xf6\xc5\x48\x25\xea\x4c\xc1\x36\x8e\x32\x03\x57\x1c\x6d\xb7\xd3\x00\x09\x8b\xf0\x2c\x67\x58\x50\xa9\x01\x99\x36\x4d\x1c\x55\x02\x29\xcb\x88\x42\x09\xb7\x77\xed\x47\x1a\x9e\x1b\x5b\xad\xff\xb9\x42\x81\x40\x28\x95\x40\x80\xe3\x03\xb4\xab\x8d\xca\x81\x09\x69\x9c\xd7\x3c\x83\x71\x08\x5e\xd3\xc0\x69\x57\xe1\x89\x95\x38\xae\x24\xa4\x69\x3a\x7c\xf4\xa4\xbf\x49\x9b\xd7\x15\x9b\x06\x16\xcc\x81\x54\x15\x72\x3a\x3e\xb8\xe4\x0c\x2a\x99\xa6\xe9\x24\x8e\x04\xaa\x5a\x70\xe8\x38\xd8\xda\xba\xdd\xc2\x03\x53\x2b\xc0\x47\x85\x9c\xc2\x08\x92\x1f\xec\xf9\x49\xc7\xeb\x51\x87\x67\x12\x95\xd2\x2b\x52\x47\x08\xbd\xb3\xf9\xa3\xc2\x9c\xab\x90\x2e\x51\xee\x8b\x9c\xcd\xe0\x86\x6c\x10\xf0\x11\xb3\x5a\x9b\xad\xa1\xff\x56\xa3\x78\x02\xc2\x29\x58\xc3\xec\x28\xaf\xd7\x0b\x14\x3a\x04\x45\xf9\x20\x67\x1b\x14\x8a\x65\x28\x61\x4d\x54\xb6\x42\x0a\x8b\x27\x1b\x9b\x65\x85\x82\x28\x56\xf2\x21\xd7\xc1\x90\xef\xb4\x06\xe3\x4c\x3d\x42\x56\x72\x85\x8f\x4a\xc7\xa8\xfe\x3b\x81\x31\xe3\xea\x0c\x50\x88\x52\x4c\x9c\xbb\x7a\x08\x7c\x71\x82\x93\xe0\x8c\xc4\x05\x77\x62\x63\x3f\xf9\x17\x8a\xf2\x67\x52\xd4\x98\xc0\xb9\x65\xea\x20\x44\x92\x6c\xd0\x21\x64\xe8\xae\x4f\x98\xfa\x0f\x96\xf7\xe2\xd2\xca\x91\x0f\x4c\x65\xab\xbe\xe7\x53\x2a\xf4\xaf\xf4\x92\x91\x02\x33\x35\x36\xba\x1b\x31\x82\xf0\x25\xc2\xe8\xb7\x33\x18\x05\x01\xde\x06\xb6\x39\x3b\xca\x74\xa6\xda\x6e\xe1\xf7\x92\xf1\x76\x9d\x17\x26\x21\x39\x03\x9d\x4f\x2e\xe2\x28\x3a\xc0\x3c\xc3\x7b\xd9\x8a\xf4\xf8\x4e\x9c\x12\xce\xf9\x51\x44\x31\x27\x75\xa1\x42\x49\xe7\x0e\x6e\x99\x7e\xc6\x87\x71\xe2\xf3\x67\xd3\x5c\x40\xcd\x65\x5d\xe9\x0c\x88\x14\xa8\x55\x26\xd1\x22\x3d\x5c\x85\xf4\xa8\x1c\xd6\x8a\x71\x8a\x8f\x81\xbd\xe7\x5d\xf5\x02\xed\x76\xe4\xfc\xc5\xd6\x93\x7b\x34\x5f\x67\xb0\xa8\x15\x54\x84\xb3\x4c\x6a\xaf\x10\x6e\x15\x86\x32\xcb\x6a\x21\x5f\x45\xba\x5f\x86\x59\xa7\x13\xf9\x36\x8e\x48\x9e\x63\xa6\x90\x1a\x44\xb4\x9b\xfa\xf6\x04\x8a\xb3\xdc\x2c\xfa\x6e\x0e\x9c\x15\xc6\xdb\x46\xc3\x31\x0a\x31\x89\x35\x42\x0e\x12\x2f\xd3\x99\x77\xf5\x88\xd9\x40\xec\xbd\xd8\x08\xbd\x7f\xd8\x06\x8b\xc9\x36\x8e\x7e\x7b\x89\xfa\x4e\x3b\x14\x22\x50\x6c\x87\xbb\xfe\x7a\x2b\xdc\x8d\xe4\x61\x9d\xb7\x2d\x8e\x03\xda\x7a\x53\x27\xff\x7f\x1c\x69\x93\x27\x5f\x16\x68\x2f\xc9\xa7\xbd\x5c\xe2\x93\xc7\x48\xad\xab\xa2\x2d\xfb\x39\x24\x2e\x20\x66\xef\xe4\xcc\xb7\x1f\x41\x04\xda\x4d\x8f\x6d\xca\xb1\xdb\x7d\xaa\xf1\x94\xef\xa6\xfa\x51\xc9\xb1\xdf\x5f\xe4\x90\xbc\x93\x3f\x72\x4c\xf6\x7a\x86\x16\xaa\xb0\xaf\x08\x24\x04\xed\x42\x67\xf4\x68\xc7\x40\x40\x32\xbe\x2c\x70\xa0\x75\x78\x0a\x1a\x87\xae\xc0\xfd\xde\x81\x51\x2b\xe0\xfa\x32\xfd\xaa\xf7\xf8\x9c\x7a\xa4\x9f\x78\xbe\x7a\x76\x6d\x7b\x59\x01\xfd\xc3\x02\xdf\xac\x88\x5a\x41\xb4\xc5\xf0\x48\xd0\x74\x51\x3d\x5a\x25\x4f\x43\xff\xbc\x69\xbd\x4c\x38\x2b\x92\xb7\xad\x99\x7f\xb9\x92\xc9\x59\xf1\x57\x2e\x9a\x1d\x1e\x1e\xad\x9b\x1d\x1a\xfa\xee\x3a\xfd\xb2\x13\xf8\x96\x95\xb4\x2f\xfb\x78\x45\x85\xd2\xde\x27\x5f\x1b\x77\x7f\x9a\x12\x3b\xa0\xf5\x9f\xa0\xca\x06\x5a\xff\xef\x0a\xed\xee\xe7\xec\x14\xe4\x8a\x08\xa4\xbe\x88\xd9\x82\x04\x0b\x54\x0f\x88\x96\x41\xea\xa1\x74\x59\x5c\x48\x30\x4f\x0f\x7b\x2f\x0f\xbe\x8e\xd9\xb9\x00\xa3\xdc\xa2\xf3\xc9\x4a\x0d\xd2\x64\x29\x60\xcc\x4b\x05\xa3\x3c\xbd\x5e\xaf\x6b\x45\x16\x05\x4e\xf4\x97\x7d\x3e\xb8\xb4\x49\xc7\xdb\x37\xd5\x33\x37\x46\x43\x23\xaa\x25\x41\xbe\xab\xaf\x6d\x02\xb6\x63\xe9\xe7\x7a\x8d\x82\x65\x76\x2e\x22\x94\xda\xf5\x2f\x91\xe2\x73\x5f\xff\xb7\x95\xfe\x63\xa5\xef\x7a\xa4\x70\x79\xb8\x40\x22\x06\x45\x2f\xca\xb2\xe8\xc8\x08\xdd\xd1\x61\x92\xe3\xd0\x95\x2e\xb6\xed\x61\x23\xec\x0b\x5c\x93\xea\xb6\xd7\x56\xdc\x59\xb7\x6d\x5f\x2d\xbc\xd2\xa3\x89\xc0\x75\xb9\x41\xaa\x2b\x85\xce\xba\xb9\x3e\xf4\x27\xce\xbe\xd5\x68\x47\x46\x15\xcc\x21\x31\x26\xb6\xab\x42\x40\xec\x13\xd0\xa8\xda\xbd\x02\xa1\x7b\x06\xd2\xe9\x70\x4f\xa2\x46\x44\x4b\xd0\x25\xa0\x69\x8e\x99\xb3\xc7\xdc\x69\x9f\xc4\x3b\xe6\x9a\x1e\x05\x8c\x29\xa4\x78\x35\x73\x5d\x87\xe3\x9a\xca\xb0\xfd\xb4\x16\xa5\x37\x59\x59\x61\xfa\xc3\x81\xe6\xf3\xd0\xab\x56\x2f\x0e\x06\x9c\xd0\x07\xc7\x45\xbf\xc9\x78\xed\xeb\x5a\xf2\x51\x63\x9f\x0c\xe1\x1b\x47\x91\x6b\x6f\xcd\x96\xa6\x01\xe3\x27\x5b\x02\xf4\x30\xee\xfa\x57\xba\x44\x50\xa5\x1b\xb5\xd1\x61\xa7\xd2\x38\x8a\x5e\x78\x8d\x09\x4e\x1a\x0f\xbe\x2c\x45\x51\x3f\xb7\x3a\xe2\x6c\xb7\xd0\x55\x5f\x6f\x98\x83\x12\x35\x1e\x6e\x4f\x7c\xc7\xe0\xd9\xe2\xe0\x31\xbc\x2d\xca\x07\x14\x30\x6e\x2f\x08\xe9\x7b\xdd\x42\x07\x96\x4d\xfc\x86\xd9\xa9\x86\xd9\x3c\xe6\xe8\x73\x4b\xfb\xbb\x22\x82\xac\x51\xa1\xd0\xb5\x22\x2f\x98\x6e\x98\x4c\xc6\x36\x0f\xb0\x5e\x07\xb3\xc3\xb0\x26\x72\xee\xc2\x6f\x5a\x81\x0e\x4c\x6d\x90\x6c\x12\xf7\xd9\x36\x4e\x7a\x8a\x51\xf9\xa9\xeb\xd0\x2f\x26\xe4\x12\x18\xeb\x8b\x46\x5d\x10\xd1\x82\xf2\x1f\x87\xd2\x04\x92\xeb\x4b\x4b\xc9\xd6\xc5\x5e\x4e\xd3\x58\xa2\xe3\xeb\xdc\x0c\x8b\x27\x60\x54\xbe\xd2\xdb\xbb\x43\xc7\x8c\x9a\x77\xc6\x5e\xb8\x1e\xa0\x01\xcb\xf7\xaa\xac\x4b\x34\xc3\x4c\xd8\x95\xdc\x7d\x0a\x1d\xdd\x08\x6b\x72\x8f\xe3\x63\x79\x44\x37\x9e\x91\x29\x00\xfa\x9a\xc7\x4c\xb8\x9a\xa8\xd4\x06\xbd\xfa\xc4\x5b\x46\xe5\x2d\xbb\xbb\x83\x39\xb4\x89\xaa\x69\x4f\x38\xc6\xe3\xa1\xd0\x6e\x99\xf0\x92\xd8\xf6\x5e\xdf\xf7\xb8\x7c\xd3\xc8\xb6\x7c\x6e\x1a\xed\xed\xd3\x7d\xa9\x87\x3c\x4e\xa5\x36\xcc\xb8\xe3\xf6\xae\xe7\x8c\x33\x28\x90\xb7\x82\x27\x13\x9f\x29\x8c\x37\x12\xb6\x2b\x3e\x3a\xbc\x98\x5d\x65\xe7\xe7\x90\xfc\x1e\x54\x1d\x7b\x6b\x30\x9e\xb4\xf3\x4d\xb3\x73\x68\xab\xb8\xf5\xaa\xf6\x94\x5f\xa4\xfd\xe5\xa7\x77\x83\xe9\xf5\xe5\x33\xae\x4b\xf7\x83\xc0\xbe\x7e\x47\x07\x7a\xab\x03\x05\xaa\xed\xcd\xfc\x4b\xbf\xbe\x43\xc2\x1a\xd5\xaa\xa4\x3e\x25\x7d\xf0\xef\x11\x07\x0b\x95\xbd\x78\xba\xfa\xee\xff\xc5\xe3\xaa\x93\xff\xdf\xce\xd4\x4f\xff\x1b\x45\x19\xcc\xb7\xf7\xdb\x76\x7f\x58\xc0\xdc\xa2\xf6\x6a\x31\xdd\x6f\x22\xba\x7d\xdc\xb4\xdb\x10\x75\x5b\x36\xeb\xa5\x81\x1c\x30\xd8\x24\xf9\xe0\xdf\xee\x37\x57\x70\x72\x02\xdf\x0d\x96\x94\x41\x49\x2d\xf8\x96\x01\x1b\xdf\xec\x07\xff\xf8\x72\x2a\x74\xf4\x75\xc4\x6e\x15\xb8\x96\x5f\x99\x19\x19\x4f\xc2\x64\xbe\x97\x26\x86\xad\x81\x93\x4d\x87\x1e\xd3\xf0\x3e\x30\xca\xd3\x9f\x49\xc1\x28\x51\xa5\x90\xaf\xc4\x29\xb8\x97\xf4\x2e\x33\xfb\xf6\xb5\x87\x68\x2b\x4e\x5f\x22\x7e\xff\xf2\xd3\x89\x09\xc3\x26\x1d\xc8\xf9\x5a\xa5\x57\xfa\x82\x96\x77\xef\xfc\x9b\xf6\xc4\x9c\xb0\x02\xa9\x61\xba\xb9\x13\xc0\xaf\x89\x3d\xd0\xe1\xfc\x6b\x72\x01\xef\x36\x89\xb9\x3f\xb6\xc9\xb9\x8b\x57\xe7\xe7\xf3\xad\x6c\xa7\x8d\x6a\x41\xf5\x29\xa7\x6f\x79\xbf\xa9\x9e\xc0\xdf\xe0\xbd\xb5\x78\xc8\xe0\x43\x8f\x1c\xe6\x91\xa7\x2a\x10\x88\x94\x6c\xc9\xd7\xc8\x95\xd4\x37\x6e\x02\xb5\x55\xc4\xd4\x62\x6b\x3b\xee\x6c\xf7\x0f\x21\xae\x9f\x30\x17\x20\xdc\x71\xde\x25\xb8\x01\x4e\x1c\xeb\xa4\x4e\x4e\x06\x29\xb4\x77\x7d\x98\x3f\xe7\xdd\x43\xc6\x9a\xc3\xed\xeb\xe8\xf3\xd6\x79\xf3\x42\xf6\x0f\x7a\xd6\xc7\xd6\x7f\x03\x00\x00\xff\xff\xa2\x76\xad\xe6\x8b\x1f\x00\x00") +var _templateBuilderUpdateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xdc\x59\x6d\x6f\xe3\x36\xf2\x7f\x2d\x7d\x8a\xa9\xe0\x0d\xec\x20\x96\xb3\xfb\xee\x9f\x3f\x7c\x40\xbb\xc9\x02\x01\x0e\xdb\xc3\x66\xdb\x2b\x2e\x0d\x0a\x5a\x1c\xd9\x6c\x64\x52\x4b\x52\x4e\x72\x3e\x7d\xf7\x03\x9f\x64\x49\x96\x9d\xa4\x08\x70\x68\x5f\xc5\xe2\xc3\x70\xe6\x37\xcf\x93\xed\x76\x76\x1a\x7f\x14\xe5\x93\x64\xcb\x95\x86\x0f\xe7\xef\xff\x6f\x5a\x4a\x54\xc8\x35\x7c\x22\x19\x2e\x84\xb8\x87\x6b\x9e\xa5\xf0\x7d\x51\x80\x3d\xa4\xc0\xec\xcb\x0d\xd2\x34\xfe\xba\x62\x0a\x94\xa8\x64\x86\x90\x09\x8a\xc0\x14\x14\x2c\x43\xae\x90\x42\xc5\x29\x4a\xd0\x2b\x84\xef\x4b\x92\xad\x10\x3e\xa4\xe7\x61\x17\x72\x51\x71\x1a\x33\x6e\xf7\xff\x7e\xfd\xf1\xea\xf3\xcd\x15\xe4\xac\x40\xf0\x6b\x52\x08\x0d\x94\x49\xcc\xb4\x90\x4f\x20\x72\xd0\xad\xc7\xb4\x44\x4c\xe3\xd3\x59\x5d\xc7\xf1\x76\x0b\x14\x73\xc6\x11\x92\xaa\xa4\x44\x63\x02\x75\x6d\x56\x47\xe5\xfd\x12\x2e\xe6\xb0\x20\x0a\x61\x94\x7e\x14\x3c\x67\xcb\xf4\x1f\x24\xbb\x27\x4b\x04\x7f\x55\xe3\xba\x2c\x88\x46\x48\x56\x48\x28\xca\x04\x46\xfb\x5b\x6c\x5d\x0a\xa9\x5b\x5b\xa3\x45\xc5\x0a\x23\xde\xc5\x1c\x4a\xc9\xb8\x86\x71\x49\x54\x46\x0a\x18\xa5\x9f\xc9\x1a\x27\x90\xfc\xd4\xe5\x45\x62\x86\x6c\xe3\x6e\x34\xbf\x1b\x32\xfe\xd0\xba\x2a\x34\x53\x5a\x48\xc3\xe0\xc5\x1c\x96\x1a\xc6\x05\x72\x18\xa5\x37\x6e\x71\x02\xef\x2d\x0b\xb3\x19\xb4\xb9\xa8\x6b\x83\xbc\x81\x2d\xac\xe4\x42\x82\x45\x83\xf1\xa5\x3d\x6a\xd9\x32\x07\x91\x6b\xa6\x19\xaa\x34\xd6\x4f\x25\xf6\xc9\x28\x2d\xab\x4c\xc3\x36\x8e\x32\x0b\x57\x1c\x6d\xb7\xd3\x16\x12\x0e\xe1\x59\xce\xb0\xa0\xca\x00\x32\xad\xeb\x38\x2a\x25\x52\x96\x11\x8d\x0a\x6e\xef\x9a\x8f\xb4\xfd\x6e\xec\xb8\xfe\xe7\x0a\x25\x02\xa1\x54\x01\x01\x8e\x0f\xd0\x9c\xb6\x2c\xb7\x44\x48\xe3\xbc\xe2\x19\x8c\xdb\xe0\xd5\x35\x9c\x76\x19\x9e\x38\x8a\xe3\x52\x41\x9a\xa6\xc3\x4f\x4f\xfa\x97\x8c\x78\x5d\xb2\x69\x4b\x82\x39\x90\xb2\x44\x4e\xc7\x07\x8f\x9c\x41\xa9\xd2\x34\x9d\xc4\x91\x44\x5d\x49\x0e\x1d\x05\x3b\x59\xb7\x5b\x78\x60\x7a\x05\xf8\xa8\x91\x53\x18\x41\xf2\x83\x7b\x3f\xe9\x68\x3d\xea\xd8\x99\x42\xad\xcd\x89\xd4\x1b\x84\xb9\x59\xff\x51\x62\x5e\x55\x48\x97\xa8\xf6\x49\xce\x66\x70\x43\x36\x08\xf8\x88\x59\x65\xc4\x36\xd0\x7f\xab\x50\x3e\x01\xe1\x14\x9c\x60\x6e\x95\x57\xeb\x05\x4a\xe3\x82\x52\x3c\xa8\xd9\x06\xa5\x66\x19\x2a\x58\x13\x9d\xad\x90\xc2\xe2\xc9\xf9\xa6\x28\x51\x12\xcd\x04\x1f\x52\x1d\x0c\xe9\xce\x70\x30\xce\xf4\x23\x64\x82\x6b\x7c\xd4\xc6\x47\xcd\xdf\x09\x8c\x19\xd7\x67\x80\x52\x0a\x39\xf1\xea\xea\x21\xf0\xc5\x13\x4e\x5a\x6f\x24\xde\xb9\x13\xe7\xfb\xc9\xbf\x50\x8a\x9f\x49\x51\x61\x02\xe7\xce\x52\x07\x21\x52\x64\x83\x1e\x21\x6b\xee\xe6\x85\x69\xf8\x60\x79\xcf\x2f\x1d\x1d\xf5\xc0\x74\xb6\xea\x6b\x3e\xa5\xd2\xfc\x4a\x2f\x19\x29\x30\xd3\x63\xcb\xbb\x25\x23\x09\x5f\x22\x8c\x7e\x3b\x83\x51\xcb\xc1\x1b\xc7\xb6\x6f\x47\x99\x89\x54\xdb\x2d\xfc\x2e\x18\x6f\xce\x05\x62\x0a\x92\x33\x30\xf1\xe4\x22\x8e\xa2\x03\x96\x67\xed\x5e\x35\x24\x03\xbe\x13\xcf\x84\x57\x7e\x14\x51\xcc\x49\x55\xe8\x36\xa5\x73\x0f\xb7\x4a\x3f\xe3\xc3\x38\x09\xf1\xb3\xae\x2f\xa0\xe2\xaa\x2a\x4d\x04\x44\x0a\xd4\x31\x93\x18\x92\x01\xae\x42\x05\x54\x0e\x73\xc5\x38\xc5\xc7\x96\xbc\xe7\x5d\xf6\x5a\xdc\xed\x8c\xf3\x17\x97\x4f\xee\xd1\x7e\x9d\xc1\xa2\xd2\x50\x12\xce\x32\x65\xb4\x42\xb8\x63\x18\x44\x96\x55\x52\xbd\xca\xe8\x7e\x19\xb6\x3a\x13\xc8\xb7\x71\x44\xf2\x1c\x33\x8d\xd4\x22\x62\xd4\xd4\x97\xa7\xc5\x38\xcb\xed\xa1\xef\xe6\xc0\x59\x61\xb5\x6d\x39\x1c\xa3\x94\x93\xd8\x20\xe4\x21\x09\x34\xbd\x78\x57\x8f\x98\x0d\xf8\xde\x8b\x85\x30\xf7\x87\x65\x70\x98\x6c\xe3\xe8\xb7\x97\xb0\xef\xb9\x43\x29\x5b\x8c\xed\x70\x37\x5f\x6f\x85\xbb\xa5\x3c\xcc\xf3\xb6\xc1\x71\x80\xdb\x20\xea\xe4\xff\x8f\x23\x6d\xe3\xe4\xcb\x1c\xed\x25\xf1\xb4\x17\x4b\x42\xf0\x18\xe9\x75\x59\x34\x69\x3f\x87\xc4\x3b\xc4\xec\x9d\x9a\x85\xf2\xa3\xe5\x81\xee\xd2\x63\x13\x72\xdc\xf5\x10\x6a\x82\xc9\x77\x43\xfd\x48\x70\xec\xd7\x17\x39\x24\xef\xd4\x8f\x1c\x93\xbd\x9a\xa1\x81\xaa\x5d\x57\xb4\x28\xb4\xca\x85\xce\xea\xd1\x8a\x81\x80\x62\x7c\x59\xe0\x40\xe9\xf0\xd4\x2a\x1c\xba\x04\xf7\x6b\x07\x46\x1d\x81\xeb\xcb\xf4\xab\xb9\x13\x62\xea\x91\x7a\xe2\xf9\xec\xd9\x95\xed\x65\x09\xf4\x0f\x13\x7c\xb3\x24\xea\x08\xd1\x06\xc3\x23\x4e\xd3\x45\xf5\x68\x96\x3c\x6d\xeb\xe7\x4d\xf3\x65\xc2\x59\x91\xbc\x6d\xce\xfc\xcb\xa5\x4c\xce\x8a\xbf\x72\xd2\xec\xd8\xe1\xd1\xbc\xd9\x31\xc3\x50\x5d\xa7\x5f\x76\x04\xdf\x32\x93\xf6\x69\x1f\xcf\xa8\x20\x5c\x3f\xf9\x5a\xbf\xfb\xd3\xa4\xd8\x01\xae\xff\x04\x59\xb6\xc5\xf5\xff\x2e\xd1\xee\x7e\xce\x4e\x41\xad\x88\x44\x1a\x92\x98\x4b\x48\xb0\x40\xfd\x80\xe8\x2c\x48\x3f\x08\x1f\xc5\xa5\x02\x3b\x7a\xd8\x9b\x3c\x84\x3c\xe6\xf6\x5a\x18\xe5\x0e\x9d\x4f\x8e\x6a\x2b\x4c\x0a\x09\x63\x2e\x34\x8c\xf2\xf4\x7a\xbd\xae\x34\x59\x14\x38\x31\x5f\x6e\x7c\x70\xe9\x82\x4e\x90\x6f\x6a\x76\x6e\x2c\x87\x96\x54\x63\x04\xf9\x2e\xbf\x36\x01\xd8\xad\xa5\x9f\xab\x35\x4a\x96\xb9\xbd\x88\x50\xea\xce\xbf\x84\x4a\x88\x7d\xfd\xdf\x8e\xfa\x8f\xa5\xe9\xf5\x48\xe1\xe3\x70\x81\x44\x0e\x92\x5e\x08\x51\x74\x68\xb4\xd5\xd1\xb1\x24\x6f\x43\x57\x26\xd9\x36\x8f\x8d\xb0\x4f\x70\x4d\xca\xdb\x5e\x59\x71\xe7\xd4\xb6\x7d\x35\xf1\xd2\xac\x26\x12\xd7\x62\x83\xd4\x64\x0a\x13\x75\x73\xf3\xe8\x4f\x9c\x7d\xab\xd0\xad\x8c\x4a\x98\x43\x62\x45\x6c\x4e\xb5\x01\x71\x23\xa0\x51\xb9\x9b\x02\xa1\x1f\x03\x99\x70\xb8\x47\xd1\x20\x62\x28\x98\x14\x50\xd7\xc7\xc4\xd9\xb3\xdc\x69\xdf\x88\x77\x96\x6b\x6b\x14\xb0\xa2\x90\xe2\xd5\x96\xeb\x2b\x1c\x5f\x54\xb6\xcb\x4f\x27\x51\x7a\x93\x89\x12\xd3\x1f\x0e\x14\x9f\x87\xa6\x5a\x3d\x3f\x18\x50\x42\x1f\x1c\xef\xfd\x36\xe2\x35\xd3\xb5\xe4\xa3\xc1\x3e\x19\xc2\x37\x8e\x22\x5f\xde\xda\x2b\x75\x0d\x56\x4f\x2e\x05\x98\x65\xdc\xd5\xaf\x74\x89\xa0\x85\x5f\x75\xde\xe1\xb6\xd2\x38\x8a\x5e\xd8\xc6\xb4\x5e\x1a\x0f\x4e\x96\xa2\xa8\x1f\x5b\xbd\xe1\x6c\xb7\xd0\x65\xdf\x5c\x98\x83\x96\x15\x1e\x2e\x4f\x42\xc5\x10\xac\xc5\xc3\x63\xed\xb6\x10\x0f\x28\x61\xdc\x34\x08\xe9\x7b\x53\x42\xb7\x24\x9b\x84\x0b\xb3\x53\x03\xb3\x1d\xe6\x98\x77\x85\xfb\x5d\x12\x49\xd6\xa8\x51\x9a\x5c\x91\x17\xcc\x14\x4c\x36\x62\xdb\x01\x6c\xe0\xc1\xde\xb0\x56\x13\x79\x75\xe1\x37\xc3\x40\x07\xa6\xc6\x49\x36\x89\xff\x6c\x0a\x27\xb3\xc5\xa8\xfa\xd4\x55\xe8\x17\xeb\x72\x09\x8c\x4d\xa3\x51\x15\x44\x36\xa0\xfc\xc7\xa3\x34\x81\xe4\xfa\xd2\x99\x64\xa3\xe2\x40\xa7\xae\x9d\xa1\xe3\xeb\xd4\x0c\x8b\x27\x60\x54\xbd\x52\xdb\xbb\x47\xc7\x8c\xda\x39\x63\xcf\x5d\x0f\x98\x01\xcb\xf7\xb2\xac\x0f\x34\xc3\x96\xb0\x4b\xb9\xfb\x26\x74\xf4\x22\xac\xc9\x3d\x8e\x8f\xc5\x11\x53\x78\x46\x36\x01\x98\x36\x8f\x59\x77\xb5\x5e\x69\x04\x7a\xf5\x8b\xb7\x8c\xaa\x5b\x76\x77\x07\x73\x68\x02\x55\xdd\xbc\x70\xcc\x8e\x87\x5c\xbb\xb1\x84\x97\xf8\x76\xd0\xfa\xbe\xc6\xd5\x9b\x7a\xb6\xb3\xe7\xba\x36\xda\x3e\xdd\xa7\x7a\x48\xe3\x54\x19\xc1\xac\x3a\x6e\xef\x7a\xca\x38\x83\x02\x79\x43\x78\x32\x09\x91\xc2\x6a\x23\x61\xbb\xe4\x63\xdc\x8b\xb9\x53\x6e\x7f\x0e\xc9\xef\xad\xac\xe3\xba\x06\xab\x49\xb7\x5f\xd7\x3b\x85\x36\x8c\x3b\xad\x1a\x4d\x85\x43\x46\x5f\x61\x7b\xb7\x98\x5e\x5f\x3e\xa3\xba\x74\xdf\x09\xdc\xf4\x3b\x3a\x50\x5b\x1d\x48\x50\x4d\x6d\x16\x26\xfd\xa6\x87\x84\x35\xea\x95\xa0\x21\x24\x7d\x08\xf3\x88\x83\x89\xca\x35\x9e\x3e\xbf\x87\x7f\xf1\xf8\xec\x14\xfe\xb7\x33\x0d\xdb\xff\x46\x29\x5a\xfb\x4d\x7f\xdb\xdc\x6f\x27\x30\x7f\xa8\x69\x2d\xa6\xfb\x45\x44\xb7\x8e\x9b\x76\x0b\xa2\x6e\xc9\xe6\xb4\x34\x10\x03\x06\x8b\xa4\xe0\xfc\xdb\xfd\xe2\x0a\x4e\x4e\xe0\xbb\xc1\x94\x32\x48\xa9\x01\xdf\x59\xc0\x26\x14\xfb\xad\x7f\x7c\x79\x16\x3a\xfc\x7a\xc3\x6e\x18\xb8\x56\x5f\x99\x5d\x19\x4f\xda\xc1\x7c\x2f\x4c\x0c\x4b\x03\x27\x9b\x8e\x79\x4c\xdb\xfd\x80\x90\xe6\xca\xcf\xa4\x60\x94\x68\x21\x95\x7b\xee\x8a\x57\xeb\x57\x82\xd6\x6a\x52\x7a\x9d\xcd\xbe\xb0\xcd\x73\x46\xa4\xd3\x97\x90\xdf\xef\x84\x3a\x0e\x62\x4d\xcb\x78\x75\xbe\xd6\xe9\x95\xe9\xd6\xf2\xee\x00\x60\xd3\xbc\x98\x13\x56\x20\xb5\x66\x6f\x1b\x04\xf8\x35\x71\x0f\x7a\xd0\x7f\x4d\x2e\xe0\xdd\x26\xb1\xcd\x64\x13\xa9\xbb\xe0\x75\x7e\x3e\x5f\xd7\x76\x6a\xaa\x06\xd4\x10\x7f\xfa\x92\xf7\x2b\xec\x09\xfc\x0d\xde\x3b\x89\x87\x04\x3e\x34\xf1\xb0\x13\x9f\xb2\x40\x20\x4a\xb1\x25\x5f\x23\xd7\xca\xb4\xdf\x04\x2a\xc7\x88\x4d\xcc\x4e\x76\xdc\xc9\x1e\xa6\x22\xbe\xb8\xb0\xdd\x10\xee\x1c\xc0\x47\xbb\x01\x9b\x38\x56\x56\x9d\x9c\x0c\x9a\xd0\x5e\x2f\x31\x7f\x4e\xbb\x87\x84\xb5\x8f\xbb\x51\xe9\xf3\xd2\x05\xf1\xda\xae\x30\xa8\xd9\xe0\x68\xff\x0d\x00\x00\xff\xff\x02\x11\x7c\x43\x98\x1f\x00\x00") func templateBuilderUpdateTmplBytes() ([]byte, error) { return bindataRead( @@ -234,7 +234,7 @@ func templateBuilderUpdateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/update.tmpl", size: 8075, mode: os.FileMode(420), modTime: time.Unix(1568751061, 0)} + info := bindataFileInfo{name: "template/builder/update.tmpl", size: 8088, mode: os.FileMode(420), modTime: time.Unix(1570030781, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -254,7 +254,7 @@ func templateClientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/client.tmpl", size: 6205, mode: os.FileMode(420), modTime: time.Unix(1569672823, 0)} + info := bindataFileInfo{name: "template/client.tmpl", size: 6205, mode: os.FileMode(420), modTime: time.Unix(1570008718, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -454,7 +454,7 @@ func templateDialectGremlinOpenTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/open.tmpl", size: 503, mode: os.FileMode(420), modTime: time.Unix(1569672616, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/open.tmpl", size: 503, mode: os.FileMode(420), modTime: time.Unix(1570008718, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -694,7 +694,7 @@ func templateDialectSqlOpenTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/open.tmpl", size: 389, mode: os.FileMode(420), modTime: time.Unix(1569672619, 0)} + info := bindataFileInfo{name: "template/dialect/sql/open.tmpl", size: 389, mode: os.FileMode(420), modTime: time.Unix(1570008718, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -794,7 +794,7 @@ func templateEntTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/ent.tmpl", size: 3924, mode: os.FileMode(420), modTime: time.Unix(1569486438, 0)} + info := bindataFileInfo{name: "template/ent.tmpl", size: 3924, mode: os.FileMode(420), modTime: time.Unix(1569701608, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -859,7 +859,7 @@ func templateImportTmpl() (*asset, error) { return a, nil } -var _templateMetaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x56\x4d\x8f\xdb\x36\x13\x3e\x4b\xbf\x62\x5e\x41\x01\xec\x60\x43\x27\xb9\xbd\x29\x7c\x08\xb2\x09\x6a\x34\x0d\x02\x64\xdb\x1e\x16\x8b\x80\x16\x87\x6b\x26\x34\xa9\x92\xb4\x63\x43\xd0\x7f\x2f\xf8\x25\x4b\xae\xb7\x59\xf4\x63\x2f\x6b\x72\x66\x9e\x79\xe6\x99\x21\xa9\xae\x5b\x3c\x2d\xdf\xe8\xf6\x68\xc4\xfd\xc6\xc1\xcb\xe7\x2f\xfe\xff\xac\x35\x68\x51\x39\x78\x47\x1b\x5c\x6b\xfd\x15\x56\xaa\x21\xf0\x5a\x4a\x08\x4e\x16\xbc\xdd\xec\x91\x91\xf2\x66\x23\x2c\x58\xbd\x33\x0d\x42\xa3\x19\x82\xb0\x20\x45\x83\xca\x22\x83\x9d\x62\x68\xc0\x6d\x10\x5e\xb7\xb4\xd9\x20\xbc\x24\xcf\xb3\x15\xb8\xde\x29\x56\x0a\x15\xec\xef\x57\x6f\xde\x7e\xf8\xf4\x16\xb8\x90\x08\x69\xcf\x68\xed\x80\x09\x83\x8d\xd3\xe6\x08\x9a\x83\x1b\x25\x73\x06\x91\x94\x4f\x17\x7d\x5f\x96\x5d\x07\x0c\xb9\x50\x08\xd5\x16\x1d\xad\x20\x6e\x3e\x83\x6f\xc2\x6d\x00\x0f\x0e\x15\x83\x1a\xaa\x8f\xb4\xf9\x4a\xef\xb1\x82\x9a\xa4\x9f\xf0\xac\xef\xcb\xa2\xeb\xc0\xe1\xb6\x95\xd4\x21\x54\x1b\xa4\x0c\x4d\x05\xc4\xa3\x74\x1d\xf8\xd8\x94\xe4\xe4\x24\xb6\xad\x36\xae\x82\x3a\x98\x1a\xad\xac\x83\x59\x59\x2c\x16\xf0\x9e\xae\x51\xc2\x46\x4b\x66\x43\x15\xd6\x19\xa1\xee\x41\x86\x6d\x86\x4a\x3b\xbf\xf4\x96\xae\x03\xa9\xbf\xa1\x81\x9a\x7c\xa0\x5b\x84\xbe\x07\x77\x6c\x87\xf2\x19\x75\x74\x4d\x2d\x92\xb2\x88\x98\x4b\xa8\xba\x0e\x6a\x12\x57\x7d\x5f\x85\x7c\x61\x6b\x75\x4d\xde\x78\x0e\x54\x39\x0f\xf3\xa7\xec\x93\xbc\x82\x01\x17\x28\xd9\x85\x44\x97\xc0\x72\xda\xd5\x35\xf9\xe4\xb4\xa1\xf7\xf8\x13\x1e\x63\xfa\xae\x03\x43\xd5\x3d\x42\xfd\xf9\x0a\x6a\x0e\xaf\x96\x50\x93\x77\x1e\xdb\x7a\x61\x7d\x58\xcc\xe4\x0d\xfc\x84\x1a\x44\xcf\xe4\xa3\xc7\x77\x59\x9f\xd4\xe2\x83\x5c\x7b\x34\x0e\x0f\xd0\x1a\xdd\xa2\x71\xc7\x0b\x05\x15\x93\x0c\xa9\x14\x7e\xa9\x10\xdf\xe6\x3c\x0c\xa3\xa2\x6c\xf4\x8c\xa5\xa5\x30\x08\xf4\x3d\x92\xdb\xb6\xd2\x9b\x5a\x23\x94\xe3\x50\x31\x41\x25\x36\x6e\xf1\xc4\x2e\xfc\x20\x2e\x9a\x54\xb1\xad\x4e\x48\x39\xf8\x30\x4c\x53\x84\x09\xa3\x54\x9c\x06\x6e\x1e\x46\xee\x31\x54\x1e\xc3\x64\x4f\x8d\xa0\x6b\x89\xe7\x4c\xba\x0e\x04\x87\x0d\xb5\x37\x53\x36\x8f\x65\x39\x3d\x20\x82\x83\xf6\xf3\xfc\x23\xb5\xd7\xc8\xe9\x4e\xba\xb8\xf8\x95\x4a\xc1\xa8\xd3\xc6\x7a\xcf\x3d\x35\xfe\xb0\x0c\x07\xb4\x26\x3f\x8b\x03\xb2\x95\xfa\x4d\xb8\x4d\x8e\x0b\x04\xb6\xe2\x20\x14\x2c\x7d\xf3\x7d\x43\x7d\xdd\xcd\x06\xb7\x14\xfa\x9e\x84\xa1\x4c\x93\xd0\xf5\x1e\x42\xa8\xd9\x3c\x07\xa5\x29\x5c\xc2\x2d\x21\xe4\xee\xf6\x0e\x95\x8b\x93\xd9\x95\x45\x11\x52\x27\x65\xc5\x15\xd4\x9f\xbd\x72\x87\xb4\x41\x3e\xec\xb6\x01\x2c\x52\x48\x78\xb7\x3e\x9d\x80\xbe\xbf\x4b\x03\x3e\x9b\x5f\x65\xa4\x24\x40\x51\xf4\xe5\x64\xcd\x33\x87\x47\xd0\xcf\xa0\xe3\xf9\x13\x97\x0e\x55\x19\x73\xd6\x0c\x6d\x33\x34\x1c\x2a\xbf\xac\x60\xd6\x52\xdb\x50\x99\xcf\xc8\x7c\x08\xc8\x9d\xe1\x64\xe8\x0b\x27\xbf\xb4\x8c\x3a\x1c\x6d\x8c\xda\x14\x03\x43\x2a\xc1\xbd\xed\xa3\xb6\xc2\x09\xad\x72\xaf\xb2\x3a\xe9\x14\x07\x3a\x7d\xef\xaf\xff\x70\x82\x63\x9d\x7e\xd7\x88\xd6\x69\x03\x5c\x9b\x78\xdc\x87\xd3\x1b\xe4\x21\x01\x64\x8c\xb0\x84\x51\x03\x6f\x63\xc8\x38\xb9\x50\x2b\xc5\xf0\xe0\x5b\x71\x6e\x1d\x0c\xe4\x7a\x48\x1c\x46\x22\xb6\x45\x5a\xfc\x0f\x59\xf3\x8b\x84\xbf\x43\x29\x4f\xce\xf8\x02\x4a\xed\x1a\xf5\xea\xd4\x8b\x9a\xa5\xad\x78\xa3\x26\x87\xc0\x2d\x75\x6c\xa8\x2c\x87\x8e\xee\xd5\xbc\xb9\xa7\x72\x87\xa0\x15\x34\x06\xa9\xa7\x19\xea\x4c\xb7\xec\xc5\x5a\xcf\x20\x97\x63\xf5\x32\x0b\x32\x1b\x88\xaf\xec\x8d\x08\x10\x7c\xa7\x9a\xd9\x1c\x86\x5b\x22\xe2\xdf\xf8\x67\xae\xef\xe7\x0f\x16\x3e\x9d\xcc\x07\xcb\x9f\xb8\xfd\x6d\x11\x76\x01\xe5\x9f\x49\x30\x61\xf2\xaf\x08\x11\x6f\xc6\xcb\x67\x12\x6a\xe5\xe9\x45\x11\x06\x87\xb1\x3d\x7c\x48\xbc\x5a\xc2\xf0\x1e\xf8\xfc\x30\x7b\x62\xe7\x80\xc6\x68\x53\x0d\xd9\xa7\x8a\xa9\x54\xb6\xb0\x40\xbd\x42\x09\x39\x6b\x53\x4d\xc4\xa9\x92\x3a\xb0\x72\x3e\xa0\xa1\x52\x22\x83\xf5\x31\xb8\xae\x77\x42\x32\x34\x16\xd6\xc8\xb5\x41\xb0\x74\x8f\x59\x47\xc1\x01\x7f\x3f\x2b\xee\x45\x66\x52\x8c\x79\x4c\x55\x3e\xb9\xdf\x3e\xbf\x0b\x2a\xc7\x42\xa3\x82\x41\x42\x7f\xc6\x2f\x03\x9d\x3a\x90\x83\x20\xbc\x05\x45\xb1\x3f\xb1\x78\xf5\x50\xc2\xe8\xc9\x55\x70\x09\x6f\x4a\xc0\x9b\xb6\x31\x6a\x9b\x61\xc7\xaf\xcc\x97\x2b\xa8\xd5\xf8\x95\x99\xd4\x9e\xf8\x4e\xa8\x84\x8b\xe4\x4b\xb8\x39\x66\x0f\xa6\x8a\x6f\xd0\xf9\x65\x52\x84\x97\xc8\xff\x19\x74\x3b\xa3\x60\x14\x9f\xe7\xfa\x2f\x89\xfb\x76\x7f\xbe\x02\x1e\x18\x47\xc2\xbe\xf2\x6c\x2e\x7c\xff\x8c\xf1\x46\xae\xa6\xb8\xf3\x1f\x82\xe5\x7f\x4b\x50\x42\x9e\x02\x32\x11\x34\x26\x6f\xe5\x92\xf3\xff\xe4\xa1\x84\x1c\x57\xd0\xcf\x86\xce\x8e\x0f\xc7\xf8\x63\x2d\xff\x9e\x9f\x7d\x8b\xc4\x9f\x7f\x04\x00\x00\xff\xff\xc6\x30\x3b\xd2\xdf\x0c\x00\x00") +var _templateMetaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x5b\x6f\xdb\x36\x14\x7e\x96\x7e\xc5\x99\xa0\x02\x76\xe1\xca\x69\xdf\xe6\xc1\x0f\x45\x93\x62\xc6\xba\xa2\x40\xb3\xed\x21\x08\x0a\x5a\x3a\x8c\xd9\x4a\xa4\x4a\xd2\xae\x03\x41\xff\x7d\xe0\x4d\xa2\x3c\x67\xc9\xd6\x2d\x2f\xb1\x78\x6e\xdf\xb9\xf2\xb0\xeb\x96\xcf\xd3\x37\xa2\xbd\x97\xec\x6e\xa7\xe1\xd5\xc5\xcb\x1f\x5f\xb4\x12\x15\x72\x0d\x6f\x49\x89\x5b\x21\xbe\xc0\x86\x97\x05\xbc\xae\x6b\xb0\x4c\x0a\x0c\x5d\x1e\xb0\x2a\xd2\xeb\x1d\x53\xa0\xc4\x5e\x96\x08\xa5\xa8\x10\x98\x82\x9a\x95\xc8\x15\x56\xb0\xe7\x15\x4a\xd0\x3b\x84\xd7\x2d\x29\x77\x08\xaf\x8a\x8b\x40\x05\x2a\xf6\xbc\x4a\x19\xb7\xf4\x77\x9b\x37\x57\xef\x3f\x5e\x01\x65\x35\x82\x3f\x93\x42\x68\xa8\x98\xc4\x52\x0b\x79\x0f\x82\x82\x8e\x8c\x69\x89\x58\xa4\xcf\x97\x7d\x9f\xa6\x5d\x07\x15\x52\xc6\x11\xb2\x06\x35\xc9\xc0\x1d\xbe\x80\x6f\x4c\xef\x00\x8f\x1a\x79\x05\x39\x64\x1f\x48\xf9\x85\xdc\x61\x06\x79\xe1\x7f\xc2\x8b\xbe\x4f\x93\xae\x03\x8d\x4d\x5b\x13\x8d\x90\xed\x90\x54\x28\x33\x28\x8c\x96\xae\x03\x23\xeb\x8d\x8c\x4c\xac\x69\x85\xd4\x19\xe4\x96\x54\x0a\xae\x34\xcc\xd2\x64\xb9\x84\x77\x64\x8b\x35\xec\x44\x5d\x29\xeb\x85\xd2\x92\xf1\x3b\xa8\xed\x71\x85\x5c\x68\xf3\x69\x28\x5d\x07\xb5\xf8\x86\x12\xf2\xe2\x3d\x69\x10\xfa\x1e\xf4\x7d\x3b\xb8\x5f\x11\x4d\xb6\x44\x61\x91\x26\x4e\xe7\x1a\xb2\xae\x83\xbc\x70\x5f\x7d\x9f\x59\x7b\xf6\x68\x73\x59\xbc\x31\x18\x08\xd7\x46\xcd\x5f\xac\x4f\xec\xb2\x0a\x28\xc3\xba\x3a\x63\xe8\x9c\xb2\x60\x76\x73\x59\x7c\xd4\x42\x92\x3b\xfc\x05\xef\x9d\xf9\xae\x03\x49\xf8\x1d\x42\xfe\x69\x01\x39\x85\xd5\x1a\xf2\xe2\xad\xd1\xad\x4c\x60\x8d\x98\xb3\x64\x08\x74\xd4\x6a\x83\x1e\xc0\x3b\x8e\x47\x51\x8f\xd1\xa2\x43\xb8\x0e\x28\x35\x1e\xa1\x95\xa2\x45\xa9\xef\xcf\x38\x94\x4c\x2c\x78\x57\xe8\x39\x47\x4c\x9a\x43\x31\x44\x4e\x29\xc7\xe9\x5c\xf3\x62\x60\xe1\x1b\x4d\xba\x69\x6b\x43\x6a\x25\xe3\x9a\x42\x56\x31\x52\x63\xa9\x97\xcf\xd4\xd2\x14\xe2\xb2\xf4\x1e\xab\x6c\xd4\x14\x84\x8f\x43\x35\x39\x35\xb6\x94\x92\xb1\xe0\xe6\xb6\xe4\x9e\x02\xe5\x29\x48\x0e\x44\x32\xb2\xad\xf1\x14\x49\xd7\x01\xa3\xb0\x23\xea\x7a\x8a\xe6\xa9\x28\xa7\x0d\xc2\x28\x08\x53\xcf\x3f\x13\x75\x89\x94\xec\x6b\xed\x3e\x7e\x27\x35\xab\x88\x16\x52\x19\xce\x03\x91\xa6\x59\x86\x06\xcd\x8b\x5f\xd9\x11\xab\x0d\xff\x83\xe9\x5d\x90\xb3\x00\x1a\x76\x64\x1c\xd6\x26\xf9\x26\xa1\xc6\xef\x72\x87\x0d\x81\xbe\x2f\x6c\x51\xfa\x4a\xe8\x7a\xa3\x82\xf1\xd9\x3c\x08\xf9\x2a\x5c\xc3\x4d\x51\x14\xb7\x37\xb7\xc8\xb5\xab\xcc\x2e\x4d\x12\x6b\xda\x47\x96\x2d\x20\xff\x64\x22\x77\xf4\x07\xc5\xfb\x7d\x63\x95\x39\x08\x5e\xdf\x8d\x31\xc7\xa0\xef\x6f\x7d\x81\xcf\xe6\x8b\xa0\xc9\x07\x20\x49\xfa\x74\xf2\x4d\x03\x86\x27\xc0\x0f\x4a\xe3\xfa\x63\xe7\x9a\x2a\x75\x36\xf3\x0a\x55\x39\x24\x1c\x32\xf3\x99\xc1\xac\x25\xaa\x24\x75\xe8\x91\xf9\x20\x10\x32\x43\x8b\x21\x2f\xb4\xf8\xad\xad\x88\xc6\xe8\x20\x4a\x93\x13\xb4\xa6\x18\x35\xb4\x0f\x42\x31\xcd\x04\x0f\xb9\x0a\xd1\xf1\x5d\x6c\xe1\xf4\xbd\x19\xff\xb6\x83\x9d\x9f\xe6\x54\xb2\x56\x0b\x09\x54\x48\xd7\xee\x43\xf7\xda\xf0\x14\x56\x49\xac\x61\x0d\x51\x02\x6f\x9c\x48\x6c\x9c\xf1\x0d\xaf\xf0\x68\x52\x71\x4a\x1d\x08\xc5\xe5\x60\xd8\x96\x84\x4b\x4b\xad\xf0\x7f\x44\x4d\xcf\x02\x7e\x04\x52\xa8\x9c\x78\x00\xf9\x74\x45\xb9\x1a\x73\x91\x57\xfe\xc8\x4d\x54\xcf\x60\xb1\xf9\x8c\x0d\x9e\x05\xd1\x68\xae\x86\xc3\x03\xa9\xf7\x08\x82\x43\x29\x91\x18\x98\xd6\x4f\x3f\x65\xcf\xfa\x7a\xa2\x72\x1d\x47\x2f\xa0\x28\x66\x03\xf0\x8d\xba\x66\x56\x05\xdd\xf3\x72\x36\x87\x61\x4a\x38\xfd\xd7\xe6\x9a\xeb\xfb\xf9\x83\x8e\x4f\x2b\xf3\x41\xf7\x27\x6c\xff\x3a\x08\x7b\xab\xe5\xfb\x42\x30\x41\xf2\x9f\x04\xc2\x4d\xc6\xf3\x3d\x09\x39\x37\xf0\x5c\x10\x06\x86\x98\x6e\x17\x89\xd5\x1a\x86\xfb\xc0\xd8\x87\xd9\x33\x35\x07\x94\x52\xc8\x6c\xb0\x3e\x8d\x18\xf7\x6e\x33\x05\xc4\x44\xc8\x6b\x0e\xb1\xc9\x26\xc1\xc9\x7c\x74\x60\xa3\x8d\x40\x49\xea\x1a\x2b\xd8\xde\x5b\xd6\xed\x9e\xd5\x15\x4a\x05\x5b\xa4\x42\x22\x28\x72\xc0\x10\x47\x46\x01\xbf\x9e\x38\xf7\x32\x20\x49\x62\x1c\xd3\x28\x8f\xec\x37\x17\xb7\x36\xca\xce\x51\x17\x41\x1b\x42\xd3\xe3\xe7\x15\x8d\x19\x08\x42\x60\xef\x82\x24\x39\x8c\x28\x56\x0f\x19\x74\x9c\x94\x5b\x16\x7b\xa7\x58\x7d\xd3\x34\xba\xd8\x06\xb5\xf1\x2d\xf3\x79\x01\x39\x8f\x6f\x99\x89\xef\x1e\xef\x04\x8a\x1d\x24\x9f\xed\xe4\x98\x3d\x68\xca\xdd\x41\xa7\xc3\x24\xb1\x37\x91\xf9\x93\xa8\xf7\x92\x43\x24\x1f\xea\xfa\x6f\x81\x9b\x74\x7f\x5a\x00\xb5\x88\x1d\x60\xe3\x79\x20\x27\x26\x7f\x52\x1a\x22\xe5\x53\xbd\xf3\x9f\x2c\xe5\x87\x35\x70\x56\x8f\x02\x01\x08\x4a\x19\x8e\x82\xcb\xe1\xbf\xe7\xe0\xac\x8e\x3d\xe8\x67\x43\x66\xe3\xe6\x88\x97\xb5\xf0\x7b\x1e\xef\x22\xa9\x79\xd6\x84\x47\x41\xb9\x57\x5a\x34\x6e\xb9\x36\xae\x21\xdf\x37\x7e\x5c\x83\x7d\x40\x3c\xb2\xc7\xa6\x49\xd4\xcf\x57\x46\xd8\xe3\x58\x3e\x07\xd1\x30\x6d\xeb\xbd\xf5\x0f\x0a\x5b\x70\x54\x1a\x7b\x3b\xb4\x36\x0b\x67\xc4\xd5\xa3\xb5\xbd\x5a\x83\x96\xac\x09\x6f\x10\x9f\x88\xe2\xa3\x5b\x7b\xc7\xc7\x49\xbc\x26\xa3\xb3\xeb\x7d\x52\x83\xf6\x07\xe6\xd6\xe8\xa3\x69\x3a\xcb\x18\x6b\x71\x1b\x76\x9a\x26\xc9\xf0\x76\x99\xd4\xab\x89\x43\x18\x30\xc6\xe3\xa1\x46\xbb\x0e\xa6\x3b\x86\x9b\x65\xe1\x6c\xa8\xad\x60\xc8\xaf\xdc\xe8\xf6\x6c\x67\x63\xac\x54\x93\xdc\x34\x49\xdc\x70\x52\xb1\xe0\x1c\x5c\x34\x66\xf3\xf0\x1a\xb0\xc5\xe4\xab\xc4\x1d\xcd\xd4\xdc\x2e\x5d\xe9\xa3\x33\xf1\x3b\xa6\x9b\x8b\xa4\xbd\x2c\xd4\x3f\x9b\x74\xd6\xab\xc8\xec\x99\x0e\x1c\x9c\x8d\xfa\x4f\x7d\x63\xba\xdc\x9d\xa4\xd3\x75\x52\x69\x96\xc8\xe9\x7e\x78\x9a\x24\x57\xa9\xdc\x50\xe1\x02\xfa\x7e\x11\xdf\x38\x8f\x65\x6e\xe0\x5d\xa5\xe7\x7a\xd2\xdf\x7e\x53\x22\x6d\x74\x71\x65\xd0\xd3\x99\x7b\x27\x8e\xc5\xbb\x02\xc6\x6d\x94\xa3\x18\x3e\xb4\x51\xad\xe0\xd9\xd7\x6c\x31\xa5\xd8\xd6\x1f\xf6\xea\xf3\x2f\x0e\xf7\xf3\xcf\x00\x00\x00\xff\xff\x22\xa2\xe9\xc9\xc5\x10\x00\x00") func templateMetaTmplBytes() ([]byte, error) { return bindataRead( @@ -874,7 +874,7 @@ func templateMetaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/meta.tmpl", size: 3295, mode: os.FileMode(420), modTime: time.Unix(1569513414, 0)} + info := bindataFileInfo{name: "template/meta.tmpl", size: 4293, mode: os.FileMode(420), modTime: time.Unix(1570032383, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -899,7 +899,7 @@ func templateMigrateMigrateTmpl() (*asset, error) { return a, nil } -var _templateMigrateSchemaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x57\x4d\x6f\xdc\x36\x13\x3e\x4b\xbf\x62\x20\xec\xfb\x22\x31\x76\xa9\xc4\xb7\x2e\xb0\x07\xc3\x49\x00\x23\x85\x1b\xd4\xce\x29\x08\x0a\x9a\x1a\xad\x88\x95\x48\x99\xa2\x5c\x6f\x55\xfd\xf7\x82\x1f\x92\xb8\x5f\xf6\xa6\x8d\x2f\x2b\x0e\xe7\x83\xf3\xcc\x33\x1c\xba\xeb\xd2\x8b\xf8\x5a\xd6\x5b\xc5\xd7\x85\x86\xcb\x77\xef\x7f\x59\xd4\x0a\x1b\x14\x1a\x3e\x51\x86\x0f\x52\x6e\xe0\x46\x30\x02\x57\x65\x09\x56\xa9\x01\xb3\xaf\x9e\x30\x23\xf1\x7d\xc1\x1b\x68\x64\xab\x18\x02\x93\x19\x02\x6f\xa0\xe4\x0c\x45\x83\x19\xb4\x22\x43\x05\xba\x40\xb8\xaa\x29\x2b\x10\x2e\xc9\xbb\x61\x17\x72\xd9\x8a\x2c\xe6\xc2\xee\xff\x7a\x73\xfd\xf1\xf6\xee\x23\xe4\xbc\x44\xf0\x32\x25\xa5\x86\x8c\x2b\x64\x5a\xaa\x2d\xc8\x1c\x74\x10\x4c\x2b\x44\x12\x5f\xa4\x7d\x1f\xc7\x5d\x07\x19\xe6\x5c\x20\x24\x0d\x2b\xb0\xa2\x09\x38\xf1\x02\xfe\xe4\xba\x00\x7c\xd6\x28\x32\x98\x41\xf2\x85\xb2\x0d\x5d\x63\x02\x49\xc5\xd7\x8a\x6a\x4c\x60\xd1\xf7\x71\xd4\x75\xa0\xb1\xaa\x4b\xaa\x11\x92\x02\x69\x86\x2a\x01\x62\xbc\x74\x1d\x18\x5b\xe3\x8f\x57\xb5\x54\x1a\xde\x58\x75\x45\xc5\x1a\x61\xf6\xc7\x1c\x66\x02\x96\x2b\x98\x91\x5b\x99\x61\x63\x14\xa3\x28\xe9\x3a\x98\x91\x6b\x29\x72\xbe\x26\x3e\x26\xf4\x7d\x6a\xc4\x22\x10\x24\xc6\xd5\x62\x0c\x10\x25\x6b\xae\x8b\xf6\x81\x30\x59\xa5\xb9\x07\x9f\x0b\xd6\x3e\x50\x2d\x55\x8a\x42\xa7\x2e\xbf\x34\xe7\x58\x66\xc9\x39\x06\x19\xa7\x25\x32\x9d\x36\x8f\xa5\x37\x4e\xe2\xb7\x71\xfc\x44\x95\x4b\x64\x11\x66\xa2\x5d\x26\xf7\xf4\xa1\x1c\x52\x31\x1a\xe9\x05\xe4\x5c\x64\xa0\xb7\x35\x82\xb0\x55\x76\x25\x5a\x2b\x5a\x17\x63\x65\xb4\x31\x9b\x03\xcf\x01\x9f\x79\xa3\x1b\xb0\xd5\x71\x2e\x66\xd6\x6c\xb9\x02\x2e\x32\x7c\x1e\xd1\x7a\x37\x05\x39\x0d\x68\xd7\x59\x9f\x8f\x30\xd3\xe4\x96\x56\x68\x30\xb4\x47\x74\x7b\xce\xf5\xca\x98\xd9\xb5\x43\x73\xaa\x9b\x3f\x00\x93\x65\x5b\x89\xc6\xb8\xae\x69\xc3\x68\x39\xba\xfb\x1b\x6a\xc5\x85\xce\x21\xf9\x5f\x73\xed\xb4\x12\x67\x98\xa6\x60\x02\x0c\xa6\x7d\x0f\x85\x2c\xb3\xc6\xe6\x3e\x08\x73\xe9\x28\x6e\x6b\xee\x3d\xf6\x7d\xe2\xd0\x20\x36\xfa\x8e\x87\x15\x7c\xfb\x7e\xe1\x2a\x41\x5c\xb4\x2e\x8e\x0e\x20\x60\x16\x02\xed\x35\x7c\x2d\xa2\xa8\x03\xe3\x7f\xe9\x82\xb1\x31\xd8\x1c\xee\xb7\x35\x2e\xc1\xd2\x82\xb8\x3d\x23\x31\x14\x6c\xb4\xd7\x9a\x3b\x0f\xdd\xc2\xa0\x39\x63\xe4\xab\xe0\x8f\xad\xd9\x00\xf7\xb5\x04\xad\x5a\x9c\x87\xc0\x85\xea\x37\x82\x29\xac\xcc\xb5\xd0\xf7\x30\x2e\x5e\x31\xba\x6d\xcb\xd2\x57\x0a\x86\xef\x25\xf8\xc3\x4f\x7b\x47\xec\x6d\xe3\xce\x18\xb9\xe3\x7f\x59\x6b\xf3\x6b\x2d\xc9\xcb\xfa\x57\x5a\x2b\xa3\x6f\x7e\x1d\x4e\xc4\x22\x74\xda\xe2\x03\xe6\xb4\x2d\x6d\x5a\xfe\xd3\x9d\xd0\xd0\x2a\xe8\x55\x72\x10\xdb\x21\x1a\x34\x70\x14\x8d\x6c\xb3\xd5\x7f\x85\x6b\x96\xc3\xbb\x4c\xd3\x03\x58\x13\xcf\x1c\x55\x80\x8b\x5c\xaa\x8a\x6a\x2e\xc5\x79\x94\x1b\x5d\xad\xe0\xff\x9e\x6e\x36\xa0\x65\x5b\xc0\xa2\xc9\xde\xa6\xe3\x09\xb7\xdc\x23\xbe\xdd\xfb\xa2\x78\x45\xd5\xf6\x33\x6e\x97\xc7\x49\xbc\xcf\xe2\x7a\xe3\x69\x3c\x59\x0e\x15\x08\x55\xf9\x69\xc2\x8f\x64\x32\xed\x5f\x6f\x7c\xff\x8f\xcc\xdf\x3d\xe4\x37\xb3\xe4\xd0\xf7\xdf\xf7\xca\xbd\x5b\xa4\xfd\xa5\x4b\xee\x93\x54\xc8\xd7\xe2\x33\x6e\x9b\x30\xbb\x49\x7c\x34\xc3\x7c\xc8\x30\x30\x9f\xa2\xfa\x14\xee\xb6\xd5\x83\x2c\x3d\xde\xf9\x86\xb8\xf5\x08\x79\x88\xfa\x71\x58\x23\x80\xc3\x1b\xe2\xbd\x8d\x9c\x6f\x0e\x21\x3b\x04\xf7\xf2\x14\xba\xbb\x00\xb3\xf7\x03\xc0\x97\x3f\x8a\xf0\x21\xc8\xc7\x24\xfd\x7c\xac\x6a\x7a\x01\xb5\x6c\x74\x2d\x05\x82\xc2\x5c\xa1\x60\x5c\xac\x41\x4b\xa0\x4f\x92\xbb\x61\xc3\x0a\x64\x1b\x23\x2d\xa5\xac\xc7\x79\x62\xfe\x7e\xc7\xfc\x3f\x61\x36\xd9\xbf\x0e\x9b\x53\xb7\xcd\xf3\xef\x00\x1c\xee\x80\xd0\xd1\x4b\x93\xe7\x27\xa2\x3c\x5c\x73\xf9\x86\xfc\x26\xbe\xd6\x19\xd5\xbb\x43\x61\xf0\x31\x6c\x2e\xfd\x7d\x33\xde\x76\xf1\x89\x18\x7b\xae\x3f\x60\x89\x27\x5d\xbb\xcd\x73\x5d\x07\x83\x6a\xbf\x47\x87\xc1\xa2\xc9\x8d\x79\x46\xe0\x58\x07\xbf\x0c\xb9\x60\x45\xdd\xc1\x5d\x63\x68\xc0\xb3\x67\xdf\x0f\x7b\x6e\xa6\x96\x0d\x6f\x48\x9e\x3d\xef\xde\x91\xe6\x6f\x98\x99\x83\xc2\x38\x4d\x47\x8d\xd7\xf8\x79\x64\xe8\x3b\x7a\x1a\x77\xa7\x78\x76\x6e\x53\xff\xbc\xae\x3e\x42\xb8\x23\xa2\x31\xed\xe1\x63\x4f\xe5\xf8\xac\x0c\xd7\x69\x0a\xfe\xdd\xe9\x66\x1f\x2d\x4b\x3b\xe4\xb4\x13\xfa\x17\xa7\x07\x32\x8e\xbc\x6e\xf8\x9a\x1a\xc7\xdb\xeb\xaf\xda\x28\xe8\xca\x97\x26\xf3\x3c\xde\x3d\x74\x6f\xde\xce\x79\x2b\x18\x70\xc1\xf5\x9b\xb7\xd0\x9d\xfb\x86\xfe\xe1\x17\xc1\x5e\xb5\x5f\x18\x34\xe1\xb4\x0f\xb7\xa7\xb2\x8e\xd7\x0e\xac\xe0\xdc\xfb\x68\xff\x2c\x03\x04\xc1\xb7\xfb\xd7\xcb\x2f\xfe\x09\x00\x00\xff\xff\x89\x5f\xe9\xde\x49\x0e\x00\x00") +var _templateMigrateSchemaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x57\x4b\x6f\xe3\x36\x10\x3e\x4b\xbf\x62\x20\xb8\xc5\x6e\x60\x4b\x49\x6e\x35\xe0\x43\x90\xcd\x02\xc1\x16\xe9\xa2\xc9\x9e\x82\xa0\x60\xa8\x91\x45\x58\x22\x15\x8a\x4a\xe3\xaa\xfa\xef\x05\x1f\x92\xe8\x57\xec\xed\x6e\x2e\x16\xc9\x79\x70\xbe\xf9\x66\x86\x69\xdb\xe4\x2c\xbc\x16\xd5\x5a\xb2\x65\xae\xe0\xf2\xfc\xe2\xb7\x59\x25\xb1\x46\xae\xe0\x33\xa1\xf8\x2c\xc4\x0a\x6e\x39\x8d\xe1\xaa\x28\xc0\x08\xd5\xa0\xcf\xe5\x2b\xa6\x71\xf8\x90\xb3\x1a\x6a\xd1\x48\x8a\x40\x45\x8a\xc0\x6a\x28\x18\x45\x5e\x63\x0a\x0d\x4f\x51\x82\xca\x11\xae\x2a\x42\x73\x84\xcb\xf8\xbc\x3f\x85\x4c\x34\x3c\x0d\x19\x37\xe7\xbf\xdf\x5e\xdf\xdc\xdd\xdf\x40\xc6\x0a\x04\xb7\x27\x85\x50\x90\x32\x89\x54\x09\xb9\x06\x91\x81\xf2\x9c\x29\x89\x18\x87\x67\x49\xd7\x85\x61\xdb\x42\x8a\x19\xe3\x08\x51\x4d\x73\x2c\x49\x04\x76\x7b\x06\x7f\x33\x95\x03\xbe\x29\xe4\x29\x4c\x20\xfa\x4a\xe8\x8a\x2c\x31\x82\xa8\x64\x4b\x49\x14\x46\x30\xeb\xba\x30\x68\x5b\x50\x58\x56\x05\x51\x08\x51\x8e\x24\x45\x19\x41\xac\xad\xb4\x2d\x68\x5d\x6d\x8f\x95\x95\x90\x0a\x3e\x18\x71\x49\xf8\x12\x61\xf2\xd7\x14\x26\x1c\xe6\x0b\x98\xc4\x77\x22\xc5\x5a\x0b\x06\x41\xd4\xb6\x30\x89\xaf\x05\xcf\xd8\x32\x76\x3e\xa1\xeb\x12\xbd\xcd\xbd\x8d\x48\x9b\x9a\x0d\x0e\x82\x68\xc9\x54\xde\x3c\xc7\x54\x94\x49\xe6\xc0\x67\x9c\x36\xcf\x44\x09\x99\x20\x57\x89\x8d\x2f\xc9\x18\x16\x69\x74\x8a\x42\xca\x48\x81\x54\x25\xf5\x4b\xe1\x94\xa3\xf0\x63\x18\xbe\x12\x69\x03\x99\xf9\x91\x28\x1b\xc9\x03\x79\x2e\xfa\x50\xb4\x44\x72\x06\x19\xe3\x29\xa8\x75\x85\xc0\x4d\x96\x6d\x8a\x96\x92\x54\xf9\x90\x19\xa5\xd5\xa6\xc0\x32\xc0\x37\x56\xab\x1a\x4c\x76\xac\x89\x89\x51\x9b\x2f\x80\xf1\x14\xdf\x06\xb4\xce\x47\x27\x87\x01\x6d\x5b\x63\xf3\x05\x26\x2a\xbe\x23\x25\x6a\x0c\xcd\x15\xed\x99\x35\xbd\xd0\x6a\x66\x6d\xd1\x1c\xf3\xe6\x2e\x40\x45\xd1\x94\xbc\xd6\xa6\x2b\x52\x53\x52\x0c\xe6\xfe\x85\x4a\x32\xae\x32\x88\x7e\xa9\xaf\xad\x54\x64\x15\x93\x04\xb4\x83\x5e\xb5\xeb\x20\x17\x45\x5a\x9b\xd8\xfb\xcd\x4c\x58\x8a\x9b\x9c\x3b\x8b\x5d\x17\x59\x34\x62\xe3\x7d\xc3\xc2\x02\x1e\x9f\xce\x6c\x26\x62\xeb\xad\x0d\x83\x1d\x08\xa8\x81\x40\x39\x09\x97\x8b\x20\x68\x41\xdb\x9f\x5b\x67\x74\x70\x36\x85\x87\x75\x85\x73\x30\xb4\x88\xed\x99\xde\xd1\x14\xac\x95\x93\x9a\x5a\x0b\xed\x4c\xa3\x39\xa1\xf1\x37\xce\x5e\x1a\x7d\x00\xf6\x6b\x0e\x4a\x36\x38\xf5\x81\xf3\xc5\x6f\x39\x95\x58\xea\xb6\xd0\x75\x30\x2c\x8e\x28\xdd\x35\x45\xe1\x32\x05\xfd\xf7\x1c\xdc\xe5\xc7\xb3\x3d\xfa\xa6\x70\x27\x34\xbe\x67\xff\x18\x6d\xfd\x6b\x34\xe3\xf7\xe5\xaf\x94\x92\x5a\x5e\xff\x5a\x9c\x62\x83\xd0\x61\x8d\x1b\xde\x94\x26\x33\xe6\x63\x0e\x8f\x4f\xb5\x92\x8c\x2f\x5b\x18\xcb\x9c\x4d\x61\x62\xe8\x6b\x8c\xe9\xfb\xe3\xa6\x55\x78\xef\x4e\x9f\x30\x23\x4d\x61\x80\x73\x9f\x16\x03\x4d\x5c\xaf\x1b\xc4\x3b\xd1\xd9\x9c\x79\x2d\x22\x08\x06\x3e\x1b\x7e\x1d\x61\xb3\xa9\x92\x4d\x2e\xab\x3e\x1d\x23\x93\x2d\x19\x81\xf1\x4c\xc8\x92\x28\x26\xf8\x69\xa4\x1e\x4c\x2d\xe0\x57\x47\x68\xe3\xd0\xf0\xd9\xe3\xe9\xa8\x6f\xc2\x71\x94\x9e\x6f\x95\x96\x39\xfb\x2a\x59\x49\xe4\xfa\x0b\xae\xe7\xfb\xcb\x64\xbb\x4e\xaa\x95\x2b\x94\x51\xb3\xcf\x80\x2f\xca\x0e\x97\xd4\x40\x57\xdd\x60\xaa\x95\xeb\x30\x43\x6d\x6d\x5e\xf2\x51\x2f\x19\x74\xdd\xd3\x56\xba\x37\x93\xb4\xbd\xb4\xc1\x7d\x16\x12\xd9\x92\x7f\xc1\x75\xed\x47\x37\x6e\xef\x8d\x30\xeb\x23\xf4\xd4\x47\xaf\x2e\x84\xfb\x75\xf9\x2c\x0a\x87\x77\xb6\x8a\xed\x7a\x80\xdc\x47\x7d\x3f\xac\x01\xc0\x6e\x0f\xba\x30\x9e\xb3\xd5\x2e\x64\xbb\xe0\x5e\x1e\x42\x77\x13\x60\x7a\xd1\x03\x7c\xf9\xbd\x08\xef\x82\xbc\x6f\xa7\x9b\x0e\x59\x4d\xce\xa0\x12\xb5\xaa\x04\x47\x90\x98\x49\xe4\x94\xf1\x25\x28\x01\xe4\x55\x30\x3b\xce\x68\x8e\x74\xa5\x77\x0b\x21\xaa\x61\x62\xe9\xbf\x3f\x31\xfb\x21\xcc\x46\xfd\xe3\xb0\x59\x71\x53\x3c\xff\x0f\xc0\xbe\x07\xf8\x86\xde\x9b\x6d\x3f\x11\xe5\xbe\xcd\x65\xab\xf8\x0f\xfe\xad\x4a\x89\xda\x1c\x3b\xbd\x8d\xfe\x70\xee\xfa\xcd\xd0\xed\xc2\x03\x3e\xb6\x4c\x7f\xc2\x02\x0f\x9a\xb6\x87\xa7\x9a\xf6\x46\xe1\x76\x8d\xf6\xa3\x4b\xc5\xb7\xfa\xa1\x82\x43\x1e\xdc\xd2\xe7\x82\xd9\x6a\x77\x7a\x8d\xa6\x01\x4b\xdf\x5c\x3d\x6c\x99\x19\x4b\xd6\xef\x90\x2c\x7d\xdb\xec\x91\xfa\xaf\x9f\xca\xbd\xc0\x30\xaf\x07\x89\x63\xfc\xdc\xf3\xac\xb0\xf4\xd4\xe6\x0e\xf1\xec\xd4\xa2\xfe\x79\x55\xbd\x87\x70\x7b\xb6\x86\xb0\xfb\x8f\x2d\x91\xfd\xb3\xd2\x5f\x27\x09\xb8\x97\xad\x9d\x7d\xa4\x28\xcc\x90\x53\x76\xd3\xbd\x69\x1d\x90\x61\xe0\x64\xfd\xf7\xda\x30\xde\x8e\xbf\x9b\x03\xaf\x2a\xdf\x9b\xcc\xd3\x70\xf3\xd2\x9d\x7e\x9d\x67\x0d\xa7\xc0\x38\x53\x1f\x3e\x42\x7b\xea\x2b\xfd\xbb\x5f\x04\x5b\xd9\x7e\x67\xd0\xf8\xd3\xde\x3f\x1e\xd3\x3a\xb4\x1d\x58\xc0\xa9\xfd\x68\xfb\x2e\x3d\x04\xde\xb7\xfd\xe7\xce\x2d\xfe\x0b\x00\x00\xff\xff\x7a\x4a\xf3\x99\xab\x0e\x00\x00") func templateMigrateSchemaTmplBytes() ([]byte, error) { return bindataRead( @@ -914,7 +914,7 @@ func templateMigrateSchemaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/migrate/schema.tmpl", size: 3657, mode: os.FileMode(420), modTime: time.Unix(1569486069, 0)} + info := bindataFileInfo{name: "template/migrate/schema.tmpl", size: 3755, mode: os.FileMode(420), modTime: time.Unix(1570019529, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -959,7 +959,7 @@ func templateTxTmpl() (*asset, error) { return a, nil } -var _templateWhereTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\x4d\x6f\xdb\x38\x13\x3e\x4b\xbf\x62\x20\x38\x78\xed\xa2\xa6\xda\xde\xde\x05\x72\x08\xea\x14\xf5\x62\x61\x77\x37\xc5\xee\x21\x08\x16\x8c\x38\x92\x89\xc8\xa4\x42\xd2\x4e\x02\xad\xfe\xfb\x82\x14\xf5\x11\x7f\xa4\x36\x92\x00\x1b\xf4\x66\x93\x33\xc3\x99\xe7\x79\x66\x28\x96\x65\xfc\x2e\xfc\x2c\x8b\x07\xc5\xb3\x85\x81\x4f\x1f\x3e\xfe\x7f\x5c\x28\xd4\x28\x0c\x7c\xa1\x09\x5e\x4b\x79\x03\x53\x91\x10\x38\xcb\x73\x70\x46\x1a\xec\xbe\x5a\x23\x23\xe1\xf7\x05\xd7\xa0\xe5\x4a\x25\x08\x89\x64\x08\x5c\x43\xce\x13\x14\x1a\x19\xac\x04\x43\x05\x66\x81\x70\x56\xd0\x64\x81\xf0\x89\x7c\x68\x76\x21\x95\x2b\xc1\x42\x2e\xdc\xfe\x6f\xd3\xcf\xe7\xb3\x8b\x73\x48\x79\x8e\xe0\xd7\x94\x94\x06\x18\x57\x98\x18\xa9\x1e\x40\xa6\x60\x7a\x87\x19\x85\x48\xc2\x77\x71\x55\x85\x61\x59\x02\xc3\x94\x0b\x84\xe8\x6e\x81\x0a\x23\xa8\x57\xc7\x70\xc7\xcd\x02\xf0\xde\xa0\x60\x30\x80\xe8\x1b\x4d\x6e\x68\x86\x11\x0c\x88\xff\x09\xe3\xaa\x0a\x83\xb2\x04\x83\xcb\x22\xa7\x06\x21\x5a\x20\x65\xa8\x22\x20\x36\x4a\x59\x82\xf5\xf5\xa7\x74\x46\x7c\x59\x48\x65\x22\x18\xb8\xad\x38\x86\xe9\xc4\x26\x6f\x50\x69\x58\xa3\x32\x3c\x41\x0d\xd7\xd4\xa2\x20\x5d\x39\x5c\x01\x67\x28\x0c\x4f\x39\x2a\x12\xa6\x2b\x91\xc0\x74\x32\xe4\x0c\xca\x12\x06\x64\x3a\x21\xdf\x1f\x0a\x84\xaa\x1a\x41\xa1\x90\xf1\x84\x1a\x24\x6e\x6b\x46\x97\x76\x1d\xca\x30\x50\x68\x56\x4a\xec\x31\x28\x4b\xe0\x29\x64\x06\x86\x39\x0a\x18\x90\x0b\x23\x15\xcd\x70\x04\x1f\xa1\xaa\xbe\xa1\x9a\x70\x9a\x63\x62\xda\x8a\x86\x61\x60\x0b\x57\x54\x64\x08\x83\xbf\xdf\xc3\x40\xd7\x1e\xf0\xcb\x69\xe7\x5e\x03\xe4\x2c\x07\x66\x59\xe4\x76\xb3\x50\x5c\x98\x14\x22\x56\x47\x8c\x4f\x74\xdc\xa6\x14\x73\x16\x75\x91\x1a\xdf\x31\xdc\xb7\xd8\xd5\x61\x2c\x70\xef\xeb\x0c\x6c\x3a\xee\x94\x51\x58\xc3\xdc\x4b\x49\x16\xf6\x40\x59\x68\x87\x11\x78\xb2\x06\x54\x65\x76\x3d\xb2\x87\x35\x95\x0f\x64\x41\xfe\xa4\x8a\x53\xc6\x93\x7a\xd1\x99\x39\x2b\xed\xcd\x3c\x97\x2e\x86\xa3\xa0\x57\xcd\x74\x72\xa2\x23\x17\xc5\x03\x1a\x06\x71\x0c\xad\x65\x55\x01\x2d\x8a\x9c\xa3\x76\xea\xb4\xeb\x9d\x69\x47\x89\xa7\xbb\xd6\x03\xe6\x8c\x84\x81\x73\xef\xc5\x19\x36\xa9\x59\x52\x77\xa5\x4e\x08\x69\x73\x3d\x42\x1d\x2f\x2f\x8f\x23\xf4\x11\xec\x68\xb7\x33\x95\x45\x75\xa5\xd1\xbc\x70\xd0\x42\xe4\xdd\x7a\x1a\x69\x02\x1c\x23\xb1\x58\x16\x7a\x4b\x66\xbb\x85\x46\xbc\xd0\x1e\x4b\x6d\xe3\xdf\x28\x0c\x36\x7b\xbd\x57\x77\x5a\x57\xfc\xc5\xf2\xa9\xbd\x7e\xc6\x16\x4d\x21\x0d\x0c\x52\x32\xd5\xbf\x5e\xcc\x67\x75\x16\x8f\x94\x45\x75\x42\x73\x6b\xd1\x2a\x6a\x9f\xa4\xf0\x76\x45\x73\x6e\x1e\x20\x59\x60\x72\xb3\x2d\xa7\xb2\x84\xdb\x95\xb4\x45\xb5\xc1\xbc\xbe\x60\x6a\xfe\xa7\xfd\x6c\xb1\xa7\x19\xd9\x3f\xe0\xfc\x77\x12\x06\xdb\x0a\x5c\xd7\xff\x0e\x52\xd5\x2b\xc8\xea\x18\x5d\xed\x12\x96\x63\x22\xb2\xc4\xb4\x56\x87\xab\x27\xf5\xce\x9b\xe2\xf9\x81\x7a\x36\xe4\xb3\xf1\x77\x14\x06\x81\xd7\x85\xd7\xd0\x51\x6a\xb2\xbd\xa1\xdb\x49\x97\xfa\xd5\xf8\x1d\x34\x49\xea\x02\x13\x9e\xf2\xa4\x63\x41\x03\xe3\x9a\x5e\xe7\xc8\x20\x95\x0a\x96\xab\xdc\xf0\x71\x63\x6e\xaf\xe2\x0c\x05\xb8\xfb\x31\xa8\x39\xc2\xdb\x9d\x1c\x79\xcd\xf6\x38\xe0\x82\xe1\x7d\x8f\x89\x0f\x9d\x95\x4d\xef\xd4\x8a\xd6\x11\x61\xff\x0d\x13\x9a\xe7\xad\x3b\x99\xbb\xfc\x47\x4d\x59\xbd\x79\xbb\x35\xd4\x9d\xfb\xe6\x40\x5f\x1f\x32\xcf\xd7\x3f\x1c\xe7\x30\x7c\xdc\x7b\x23\x18\x36\xd3\x7a\xf4\xdc\xc9\xbe\xbf\x15\x77\x8f\xfa\x66\x4e\xd8\x98\x3c\xdf\xa8\xe6\xd0\x2b\xa0\x6d\xd5\x76\xf5\xc9\x9e\xf5\xf3\x69\x23\xa8\x15\xea\xda\x62\xb4\xa4\x37\x38\xbc\xbc\xe2\xc2\xa0\x4a\x69\x82\x65\xf5\x1e\x72\x14\xbd\x8b\x69\x64\x05\x1d\x58\x61\x71\xeb\x50\x93\xb7\xae\xe7\x41\xb0\xbe\xe4\x57\x70\x0a\x9d\xf5\x25\xbf\xb2\x1b\x95\x3f\xb9\xa1\xe5\xbf\x7c\x21\x75\x23\xe4\x65\xef\x26\xa7\x84\x57\xb9\x9e\x7a\xfd\xb4\x77\xb6\x78\x28\xce\x59\x86\x7a\xbb\x33\x7c\x4b\x60\xcd\xc0\x3f\x6d\x21\x5f\xa9\x3e\x71\x2d\xf5\x64\x5f\x7c\xa5\xda\xc6\x7d\xaa\x21\xb0\x15\x21\xb2\x0c\x77\xf5\xc3\x9b\xfa\x7e\xb1\xe5\x46\x16\xd4\xe3\x65\x60\xeb\x8f\x17\xf4\x75\x54\x50\xa3\xd9\x65\x70\xa2\xff\xe2\x66\x11\xb5\x28\xbf\x2c\x8d\x35\x2a\x14\x32\xbe\x46\x01\x89\x14\x8c\x1b\x2e\x85\x86\xa1\x34\x0b\x54\xbd\x1b\x69\xb4\x8b\x71\xbb\xad\x81\x10\xf2\x98\x56\x74\x03\xad\x39\xe8\x67\x93\xc5\x5d\xcd\xd7\xab\x7d\xbf\xc6\x31\x9c\x09\x06\x99\x92\xab\xc2\x3e\xc8\xb5\xb1\xef\xe7\xde\xb7\x83\x2b\xc9\xbd\xcc\x67\x13\x90\x05\x2a\x6a\xa4\x82\x6b\x34\x77\x88\x4e\x0e\x4b\xff\x46\x3d\x13\x6c\xd8\xf3\xdb\xe2\xf1\x10\x06\xdf\xc2\xb3\x95\x8a\xc3\xde\xad\x64\xdf\xbb\x35\x8e\x61\xae\x0e\x41\x7c\xfe\xc7\x93\x80\xcf\xd5\x4f\x81\xb7\x54\xcf\x86\x7b\x26\xcd\xa3\xc9\x66\xbf\xb2\x5a\x64\xfd\x50\xab\x87\x56\x87\x44\x8d\xf1\x4c\x9a\x61\xb1\x07\x9f\xb7\x0e\xac\x90\xe6\x79\xc8\x76\x63\xe4\xdf\x00\x00\x00\xff\xff\x31\x40\x4d\x1b\x1c\x14\x00\x00") +var _templateWhereTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xe4\x57\x4d\x6f\xdc\x36\x13\x3e\x4b\xbf\x62\x20\xc8\x78\xb5\x41\x4c\x25\xb9\xbd\x05\x7c\x30\x62\x07\xd9\xa2\xb0\xd3\x3a\x68\x0f\x41\x50\xd0\xe2\x48\x22\xac\x25\x15\x92\xbb\x8e\xa1\xea\xbf\x17\xfc\xd0\x87\xd7\x6b\x67\x8d\xc4\x40\x8d\xdc\x76\xc9\xe1\x70\xe6\x79\x9e\x99\xa1\xba\x2e\x7f\x11\xbf\x95\xed\x8d\xe2\x55\x6d\xe0\xcd\xab\xd7\xff\x3f\x6c\x15\x6a\x14\x06\xde\xd1\x02\x2f\xa5\xbc\x82\xa5\x28\x08\x1c\x37\x0d\x38\x23\x0d\x76\x5f\x6d\x90\x91\xf8\x63\xcd\x35\x68\xb9\x56\x05\x42\x21\x19\x02\xd7\xd0\xf0\x02\x85\x46\x06\x6b\xc1\x50\x81\xa9\x11\x8e\x5b\x5a\xd4\x08\x6f\xc8\xab\x61\x17\x4a\xb9\x16\x2c\xe6\xc2\xed\xff\xb6\x7c\x7b\x7a\x76\x71\x0a\x25\x6f\x10\xc2\x9a\x92\xd2\x00\xe3\x0a\x0b\x23\xd5\x0d\xc8\x12\xcc\xec\x32\xa3\x10\x49\xfc\x22\xef\xfb\x38\xee\x3a\x60\x58\x72\x81\x90\x5c\xd7\xa8\x30\x01\xbf\x7a\x08\xd7\xdc\xd4\x80\x5f\x0d\x0a\x06\x29\x24\x1f\x68\x71\x45\x2b\x4c\x20\x25\xe1\x27\x1c\xf6\x7d\x1c\x75\x1d\x18\x5c\xb5\x0d\x35\x08\x49\x8d\x94\xa1\x4a\x80\x58\x2f\x5d\x07\xf6\x6c\xb8\x65\x32\xe2\xab\x56\x2a\x93\x40\xea\xb6\xf2\x1c\x96\x27\x36\x78\x83\x4a\xc3\x06\x95\xe1\x05\x6a\xb8\xa4\x16\x05\xe9\xd2\xe1\x0a\x38\x43\x61\x78\xc9\x51\x91\xb8\x5c\x8b\x02\x96\x27\x19\x67\xd0\x75\x90\x92\xe5\x09\xf9\x78\xd3\x22\xf4\xfd\x02\x5a\x85\x8c\x17\xd4\x20\x71\x5b\x67\x74\x65\xd7\xa1\x8b\x23\x85\x66\xad\xc4\x3d\x06\x5d\x07\xbc\x84\xca\x40\xd6\xa0\x80\x94\x5c\x18\xa9\x68\x85\x0b\x78\x0d\x7d\xff\x01\xd5\x09\xa7\x0d\x16\x66\xcc\x28\x8b\x23\x9b\xb8\xa2\xa2\x42\x48\xff\x7e\x09\xa9\xf6\x27\xe0\x97\xa3\xe9\xb8\x07\xc8\x59\xa6\x66\xd5\x36\x76\xb3\x55\x5c\x98\x12\x12\xe6\x3d\xe6\x07\x3a\x1f\x43\xca\x39\x4b\x26\x4f\xc3\xd9\x43\xf8\x3a\x62\xe7\xdd\x58\xe0\x5e\xfa\x08\x6c\x38\xee\x96\x45\xec\x61\x9e\x85\x24\x5b\x7b\xa1\x6c\xb5\xc3\x08\x02\x59\x29\x55\x95\x5d\x4f\xec\x65\x43\xe6\xa9\x6c\xc9\x9f\x54\x71\xca\x78\xe1\x17\x9d\x99\xb3\xd2\xc1\x2c\x70\xe9\x7c\x38\x0a\x66\xd9\x2c\x4f\x0e\x74\xe2\xbc\x04\x40\xe3\x28\xcf\x61\xb4\xec\x7b\xa0\x6d\xdb\x70\xd4\x4e\x9d\x76\x7d\x32\x9d\x28\x09\x74\x7b\x3d\x60\xc3\x48\x1c\xb9\xe3\x33\x3f\xd9\x10\x9a\x25\x75\x57\xe8\x84\x90\x31\xd6\x47\xa8\xe3\xc7\xcb\xe3\x11\xfa\x88\x76\x94\xdb\xb1\xaa\x12\x9f\x69\x72\xde\x3a\x68\x21\x09\xc7\x66\x1a\x19\x1c\x3c\x46\x62\xb9\x6c\xf5\x1d\x99\xed\x16\x1a\x09\x42\xbb\x2d\xb5\xad\x7f\x8b\x38\xda\xae\xf5\x59\xde\xa5\xcf\xf8\x9d\xe5\x53\x07\xfd\xe4\x2f\xe0\xd7\x8b\xf3\x33\x28\xa8\x10\xd2\xc0\xa5\x6d\x7f\xab\x96\x2a\xdb\xf6\x34\x17\x15\x24\x47\x09\x50\xc1\xe0\x54\xac\x57\x50\x53\x0d\x14\x8c\xe5\xd0\x77\x2a\xe6\xb1\xb2\x4a\x71\x32\x01\x61\x59\x72\xed\xcc\x65\xc1\x4b\xb0\x6e\x33\xa9\x20\x2d\xc9\x52\xbb\xbb\xdc\x2f\xeb\x6f\xe1\x33\xbe\xa5\x62\xaa\x0b\xda\x58\x93\x51\xbd\xf7\xc9\x17\xbf\xac\x69\xc3\xcd\x0d\x14\x35\x16\x57\x77\xa5\xdb\x75\xf0\x65\x2d\x2d\x80\xa3\xb3\xa0\x65\x58\x9a\xff\xe9\xd0\xc7\xec\x6d\x46\xce\x2f\x38\xfd\x9d\xc4\xd1\x5d\xb5\x6f\xfc\xbf\xbd\x14\xfc\x04\x12\x7e\x8c\x86\x77\x89\xd8\xb1\x9e\x58\x11\x8c\x56\xfb\x2b\xb5\x0c\x87\xb7\x85\xfa\x0d\xa5\x6e\x49\x75\xeb\xef\x22\x8e\xa2\x20\x93\xa0\xd7\x47\x29\xd7\xd6\xa1\x1e\xbb\x6a\x39\xe9\x79\x08\x52\xb7\x58\xf0\x92\x17\x13\x0b\x1a\x18\xd7\xf4\xb2\x41\x06\xa5\x54\xb0\x5a\x37\x86\x1f\x0e\xe6\x76\xec\x57\x28\x46\xf1\x5a\x8e\xf0\xcb\x4e\x8e\x82\x66\x67\x1c\x70\xc1\xf0\xeb\x8c\x89\x57\x93\x95\x0d\xef\xc8\x8a\xd6\x11\x61\xff\x65\x05\x6d\x9a\xf1\x38\x39\x77\xf1\x2f\x86\xb4\x66\xbd\xfd\xce\x00\x71\xc7\xb7\x87\xc7\x66\x9f\xd9\xb1\xf9\xe6\xe8\x80\xec\x76\xed\x2d\x20\x1b\x26\xc3\x18\x5b\xea\x4a\xdf\x06\xe2\xeb\x80\x5c\x18\x65\x9b\xc4\x78\xff\x50\xd9\xe1\x72\x67\x7e\x04\x46\xf1\xd5\xf0\x50\xf1\x6b\xd3\xc3\xe5\x56\x50\xdf\x31\xa8\xee\xaf\xf6\xdd\x93\x2b\x74\x26\xe7\x93\x37\x5b\x80\xed\x3b\xd1\x8c\xef\x05\xe3\xda\x83\x4d\x21\xf4\xc3\x2d\x97\xb6\x12\x36\x16\xd2\x15\xbd\xc2\xec\xd3\x67\x2e\x0c\xaa\x92\x16\xd8\xf5\x2f\xa1\x41\x31\x9b\xb2\x0b\x5b\x31\x91\x55\x2e\xb7\x07\xbc\x3a\x36\xbe\xe1\x44\x9b\x4f\xfc\x33\x1c\xc1\x64\xfd\x89\x7f\xb6\x1b\x7d\xb8\x79\x80\xf8\xbf\x3c\x5d\xa7\x1e\xf5\x63\x07\xad\xd3\xc1\x93\xcc\xda\x59\xc1\xde\xdb\xbc\x02\x14\xa7\xac\x42\x7d\xb7\xf4\x42\xcd\xa1\x67\xe0\x9f\x31\x91\xf7\x54\x1f\xb8\x9a\x7d\xb0\x2a\xde\x53\x6d\xfd\x3e\x54\x0e\x38\x8a\x10\x59\x85\xbb\xaa\xe1\x59\x3d\xc6\x6c\xba\x89\x05\xf5\xf1\x32\xb0\xf9\xe7\x35\x7d\x1a\x15\x78\x34\xa7\x08\x0e\xf4\x5f\xdc\xd4\xc9\x88\xf2\x8f\xa5\xd1\xa3\x42\xa1\xe2\x1b\x14\x50\x48\xc1\xb8\xe1\x52\x68\xc8\xa4\xa9\x51\xcd\x46\xde\x62\x17\xe3\x76\x5b\x03\x21\xe4\x36\xad\xe8\x9b\x7a\xb8\xe8\x67\x93\xc5\xb5\xe7\xeb\xc9\x1e\xe3\x79\x0e\xc7\x82\x41\xa5\xe4\xba\xd5\xd0\x70\x6d\x40\x96\xf3\xc7\xc9\xf8\x94\x3e\x3e\x3b\x01\xd9\xa2\xa2\x46\x2a\xb8\x44\x73\x8d\xe8\xe4\xb0\x0a\x1f\xdc\xc7\x82\x65\xb3\x73\x77\x78\xdc\x87\xc1\xe7\xf0\x0d\x4e\xc5\x7e\x1f\xe1\xe4\xbe\x8f\xf0\x3c\x87\x73\xb5\x0f\xe2\xe7\x7f\x3c\x08\xf8\xb9\xfa\x29\xf0\x96\xea\xbb\xe1\x3e\x93\xe6\x56\x67\xb3\x6f\xac\x11\xd9\xd0\xd4\x7c\xd3\x9a\x90\xf0\x18\x9f\x49\x93\xb5\xf7\xe0\xf3\xdc\x81\x15\xd2\x7c\x1f\xb2\x53\x1b\xf9\x37\x00\x00\xff\xff\xc3\xe8\x67\x3f\xe9\x14\x00\x00") func templateWhereTmplBytes() ([]byte, error) { return bindataRead( @@ -974,7 +974,7 @@ func templateWhereTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/where.tmpl", size: 5148, mode: os.FileMode(420), modTime: time.Unix(1568884892, 0)} + info := bindataFileInfo{name: "template/where.tmpl", size: 5353, mode: os.FileMode(420), modTime: time.Unix(1570012859, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/predicate.go b/entc/gen/predicate.go index 1569238ad..959f03a6b 100644 --- a/entc/gen/predicate.go +++ b/entc/gen/predicate.go @@ -65,7 +65,8 @@ var ( } // operations per type. boolOps = []Op{EQ, NEQ} - numericOps = append(boolOps[:], GT, GTE, LT, LTE, In, NotIn) + enumOps = append(boolOps[:], In, NotIn) + numericOps = append(enumOps[:], GT, GTE, LT, LTE) stringOps = append(numericOps[:], Contains, HasPrefix, HasSuffix) nillableOps = []Op{IsNil, NotNil} ) diff --git a/entc/gen/template/builder/create.tmpl b/entc/gen/template/builder/create.tmpl index f41eacbf3..4c341b85c 100644 --- a/entc/gen/template/builder/create.tmpl +++ b/entc/gen/template/builder/create.tmpl @@ -42,7 +42,7 @@ func ({{ $receiver }} *{{ $builder }}) Save(ctx context.Context) (*{{ $.Name }}, {{ end -}} } {{ end -}} - {{ with $f.Validators -}} + {{ with or $f.Validators $f.IsEnum -}} {{/* add nullable check only for optional fields without default value */ -}} {{ $nullable := and $f.Optional (not $f.Default) -}} {{- if $nullable }} if {{ $receiver }}.{{ $f.StructField }} != nil { {{ end -}} diff --git a/entc/gen/template/builder/update.tmpl b/entc/gen/template/builder/update.tmpl index cb05e5f5c..45082abba 100644 --- a/entc/gen/template/builder/update.tmpl +++ b/entc/gen/template/builder/update.tmpl @@ -229,7 +229,7 @@ func ({{ $receiver }} *{{ $onebuilder }}) ExecX(ctx context.Context) { {{ $receiver }}.{{ $f.StructField }} = &v } {{ end -}} - {{ with $f.Validators -}} + {{ with or $f.Validators $f.IsEnum -}} if {{ $receiver }}.{{ $f.StructField }} != nil { if err := {{ $.Package }}.{{ $f.Validator }}(*{{ $receiver }}.{{ $f.StructField }}); err != nil { return {{ $zero }}, fmt.Errorf("{{ $pkg }}: validator failed for field \"{{ $f.Name }}\": %v", err) diff --git a/entc/gen/template/meta.tmpl b/entc/gen/template/meta.tmpl index 8cb772b23..b4cae8f8f 100644 --- a/entc/gen/template/meta.tmpl +++ b/entc/gen/template/meta.tmpl @@ -95,4 +95,36 @@ var ( ) {{ end }} + +{{/* define custom type for enum fields */}} +{{ range $_, $f := $.Fields -}} + {{ if $f.IsEnum }} + {{/* omit the package name from the type. */}} + {{ $enum := trimPackage $f.Type.String $.Package }} + // {{ $enum }} defines the type for the {{ $f.Name }} enum field. + type {{ $enum }} string + + const ( + {{- range $_, $e := $f.Enums }} + {{ pascal $f.Name }}{{ pascal $e }} {{ $enum }} = "{{ $e }}" + {{- end }} + ) + + func (s {{ $enum }}) String() string { + return string(s) + } + + {{ $name := $f.Validator -}} + // {{ $name }} is a validator for the "{{ $f.Name }}" field enum values. It is called by the builders before save. + func {{ $name }}({{ $f.Name }} {{ $enum }}) error { + switch {{ $f.Name }} { + case {{ range $i, $e := $f.Enums }}{{ if ne $i 0 }},{{ end }}{{ pascal $f.Name }}{{ pascal $e }}{{ end }}: + return nil + default: + return fmt.Errorf("{{ $.Package }}: invalid enum value for {{ $f.Name }} field: %q", {{ $f.Name }}) + } + } + {{ end }} +{{ end }} + {{ end }} \ No newline at end of file diff --git a/entc/gen/template/migrate/schema.tmpl b/entc/gen/template/migrate/schema.tmpl index d796713f4..eb698f36d 100644 --- a/entc/gen/template/migrate/schema.tmpl +++ b/entc/gen/template/migrate/schema.tmpl @@ -34,6 +34,7 @@ var ( {{- if $c.Nullable }} Nullable: {{ $c.Nullable }},{{ end }} {{- with $c.Size }} Size: {{ . }},{{ end }} {{- with $c.Attr }} Attr: "{{ . }}",{{ end }} + {{- with $c.Enums }} Enums: []string{ {{ range $i, $e := . }}"{{ $e }}",{{ end }} },{{ end }} {{- with $c.Default }} Default: {{ $node.Package }}.{{ . }},{{ end }}}, {{- end }} } diff --git a/entc/gen/template/where.tmpl b/entc/gen/template/where.tmpl index 307ca3ef1..63c07849e 100644 --- a/entc/gen/template/where.tmpl +++ b/entc/gen/template/where.tmpl @@ -39,7 +39,8 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { {{ end }} {{ range $_, $f := $.Fields }} - {{- if not $f.IsJSON }} + {{/* JSON cannot be compared using "=" and Enum has a type defined with the field name */}} + {{- if not (or $f.IsJSON $f.IsEnum) }} {{ $func := pascal $f.Name }} // {{ $func }} applies equality check predicate on the {{ quote $f.Name }} field. It's identical to {{ $func }}EQ. func {{ $func }}(v {{ $f.Type }}) predicate.{{ $.Name }} { @@ -65,8 +66,9 @@ func ID(id {{ $.ID.Type }}) predicate.{{ $.Name }} { {{ range $_, $op := $ops }} {{ $arg := "v" }}{{ if $op.Variadic }}{{ $arg = "vs" }}{{ end }} {{ $func := print (pascal $f.Name) ($op.Name) }} + {{ $type := $f.Type.String }}{{ if $f.IsEnum }}{{ $type = trimPackage $type $.Package }}{{ end }} // {{ $func }} applies the {{ $op.Name }} predicate on the {{ quote $f.Name }} field. - func {{ $func }}({{ if not $op.Niladic }}{{ $arg }} {{ if $op.Variadic }}...{{ end }}{{ $f.Type }}{{ end }}) predicate.{{ $.Name }} { + func {{ $func }}({{ if not $op.Niladic }}{{ $arg }} {{ if $op.Variadic }}...{{ end }}{{ $type }}{{ end }}) predicate.{{ $.Name }} { {{- if $op.Variadic }} v := make([]interface{}, len({{ $arg }})) for i := range v { diff --git a/entc/gen/type.go b/entc/gen/type.go index 0f27cdcf2..b99211ebb 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -154,6 +154,12 @@ func NewType(c Config, schema *load.Schema) (*Type, error) { return nil, fmt.Errorf("unique field %q cannot have default value", f.Name) case typ.fields[f.Name] != nil: return nil, fmt.Errorf("field %q redeclared for type %q", f.Name, typ.Name) + case f.Info.Type == field.TypeEnum: + if err := validEnums(f); err != nil { + return nil, err + } + // enum types should be named as follows: typepkg.Field. + f.Info.Ident = fmt.Sprintf("%s.%s", typ.Package(), pascal(f.Name)) } typ.Fields[i] = &Field{ def: f, @@ -427,6 +433,14 @@ func (f Field) StructField() string { return f.Name } +// Enums returns the enum values of a field. +func (f Field) Enums() []string { + if f.IsEnum() { + return f.def.Enums + } + return nil +} + // Validator returns the validator name. func (f Field) Validator() string { return pascal(f.Name) + "Validator" } @@ -442,12 +456,15 @@ func (f Field) IsString() bool { return f.Type != nil && f.Type.Type == field.Ty // IsInt returns true if the field is an int field. func (f Field) IsInt() bool { return f.Type != nil && f.Type.Type == field.TypeInt } +// IsEnum returns true if the field is an enum field. +func (f Field) IsEnum() bool { return f.Type != nil && f.Type.Type == field.TypeEnum } + // NullType returns the sql null-type for optional and nullable fields. func (f Field) NullType() string { switch f.Type.Type { case field.TypeJSON: return "[]byte" - case field.TypeString: + case field.TypeString, field.TypeEnum: return "sql.NullString" case field.TypeBool: return "sql.NullBool" @@ -466,6 +483,8 @@ func (f Field) NullType() string { // It also does the type conversion if needed. func (f Field) NullTypeField(rec string) string { switch f.Type.Type { + case field.TypeEnum: + return fmt.Sprintf("%s(%s.String)", f.Type, rec) case field.TypeString, field.TypeBool, field.TypeInt64, field.TypeFloat64: return fmt.Sprintf("%s.%s", rec, strings.Title(f.Type.String())) case field.TypeTime: @@ -481,12 +500,14 @@ func (f Field) NullTypeField(rec string) string { // Column returns the table column. It sets it as a primary key (auto_increment) in case of ID field. func (f Field) Column() *schema.Column { + f.Enums() pk := f.Name == "id" c := &schema.Column{ Name: f.StorageKey(), Type: f.Type.Type, Unique: f.Unique, Nullable: f.Optional, + Enums: f.Enums(), } if pk { c.Type = field.TypeInt @@ -513,7 +534,14 @@ func (f Field) ExampleCode() string { case t == field.TypeTime: return "time.Now()" case t == field.TypeString: - return "\"string\"" + return `"string"` + case t == field.TypeEnum: + enums := f.Enums() + if len(enums) == 0 { + return `""` + } + parts := strings.Split(f.Type.Ident, ".") + return fmt.Sprintf("%s.%s%s", parts[0], pascal(f.Name), pascal(enums[0])) default: return "nil" } @@ -637,3 +665,21 @@ func structTag(name, tag string) string { } return tag } + +func validEnums(f *load.Field) error { + if len(f.Enums) == 0 { + return fmt.Errorf("missing values for enum field %q", f.Name) + } + values := make(map[string]bool, len(f.Enums)) + for _, e := range f.Enums { + switch { + case e == "": + return fmt.Errorf("%q field value cannot be empty", f.Name) + case values[e]: + return fmt.Errorf("duplicate values %q for enum field %q", e, f.Name) + default: + values[e] = true + } + } + return nil +} diff --git a/entc/gen/type_test.go b/entc/gen/type_test.go index 9fb6bb3ca..ec8c30a0a 100644 --- a/entc/gen/type_test.go +++ b/entc/gen/type_test.go @@ -42,6 +42,24 @@ func TestType(t *testing.T) { }) require.Error(err, "field foo redeclared") require.Nil(typ) + + typ, err = NewType(Config{Package: "entc/gen"}, &load.Schema{ + Name: "T", + Fields: []*load.Field{ + {Name: "enums", Info: &field.TypeInfo{Type: field.TypeEnum}, Enums: []string{"A", "A"}}, + }, + }) + require.Error(err, "duplicate enums") + require.Nil(typ) + + typ, err = NewType(Config{Package: "entc/gen"}, &load.Schema{ + Name: "T", + Fields: []*load.Field{ + {Name: "enums", Info: &field.TypeInfo{Type: field.TypeEnum}, Enums: []string{""}}, + }, + }) + require.Error(err, "empty value for enums") + require.Nil(typ) } func TestType_Label(t *testing.T) { diff --git a/entc/integration/config/ent/user/where.go b/entc/integration/config/ent/user/where.go index cf5ff2434..f377914cd 100644 --- a/entc/integration/config/ent/user/where.go +++ b/entc/integration/config/ent/user/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.User { return predicate.User( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { return predicate.User( diff --git a/entc/integration/ent/card/where.go b/entc/integration/ent/card/where.go index 5d46bb039..e7b60e21d 100644 --- a/entc/integration/ent/card/where.go +++ b/entc/integration/ent/card/where.go @@ -56,58 +56,6 @@ func IDNEQ(id string) predicate.Card { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.Card { - return predicate.CardPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.Card { - return predicate.CardPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.Card { - return predicate.CardPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.Card { - return predicate.CardPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.Card { return predicate.CardPerDialect( @@ -160,6 +108,58 @@ func IDNotIn(ids ...string) predicate.Card { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Card { + return predicate.CardPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Card { + return predicate.CardPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Card { + return predicate.CardPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Card { + return predicate.CardPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. func CreatedAt(v time.Time) predicate.Card { return predicate.CardPerDialect( @@ -220,6 +220,50 @@ func CreatedAtNEQ(v time.Time) predicate.Card { ) } +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.Card { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CardPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldCreatedAt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldCreatedAt, p.Within(v...)) + }, + ) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.Card { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CardPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldCreatedAt, p.Without(v...)) + }, + ) +} + // CreatedAtGT applies the GT predicate on the "created_at" field. func CreatedAtGT(v time.Time) predicate.Card { return predicate.CardPerDialect( @@ -268,50 +312,6 @@ func CreatedAtLTE(v time.Time) predicate.Card { ) } -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.Card { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CardPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldCreatedAt, p.Within(v...)) - }, - ) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.Card { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CardPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldCreatedAt, p.Without(v...)) - }, - ) -} - // UpdatedAtEQ applies the EQ predicate on the "updated_at" field. func UpdatedAtEQ(v time.Time) predicate.Card { return predicate.CardPerDialect( @@ -336,6 +336,50 @@ func UpdatedAtNEQ(v time.Time) predicate.Card { ) } +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Card { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CardPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUpdatedAt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUpdatedAt, p.Within(v...)) + }, + ) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Card { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CardPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUpdatedAt, p.Without(v...)) + }, + ) +} + // UpdatedAtGT applies the GT predicate on the "updated_at" field. func UpdatedAtGT(v time.Time) predicate.Card { return predicate.CardPerDialect( @@ -384,50 +428,6 @@ func UpdatedAtLTE(v time.Time) predicate.Card { ) } -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.Card { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CardPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUpdatedAt, p.Within(v...)) - }, - ) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.Card { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CardPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUpdatedAt, p.Without(v...)) - }, - ) -} - // NumberEQ applies the EQ predicate on the "number" field. func NumberEQ(v string) predicate.Card { return predicate.CardPerDialect( @@ -452,6 +452,50 @@ func NumberNEQ(v string) predicate.Card { ) } +// NumberIn applies the In predicate on the "number" field. +func NumberIn(vs ...string) predicate.Card { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CardPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNumber), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNumber, p.Within(v...)) + }, + ) +} + +// NumberNotIn applies the NotIn predicate on the "number" field. +func NumberNotIn(vs ...string) predicate.Card { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CardPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNumber), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNumber, p.Without(v...)) + }, + ) +} + // NumberGT applies the GT predicate on the "number" field. func NumberGT(v string) predicate.Card { return predicate.CardPerDialect( @@ -500,50 +544,6 @@ func NumberLTE(v string) predicate.Card { ) } -// NumberIn applies the In predicate on the "number" field. -func NumberIn(vs ...string) predicate.Card { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CardPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNumber), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNumber, p.Within(v...)) - }, - ) -} - -// NumberNotIn applies the NotIn predicate on the "number" field. -func NumberNotIn(vs ...string) predicate.Card { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CardPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNumber), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNumber, p.Without(v...)) - }, - ) -} - // NumberContains applies the Contains predicate on the "number" field. func NumberContains(v string) predicate.Card { return predicate.CardPerDialect( diff --git a/entc/integration/ent/comment/where.go b/entc/integration/ent/comment/where.go index 1457820a6..02ddf71c1 100644 --- a/entc/integration/ent/comment/where.go +++ b/entc/integration/ent/comment/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.Comment { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.Comment { - return predicate.CommentPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.Comment { - return predicate.CommentPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.Comment { - return predicate.CommentPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.Comment { - return predicate.CommentPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.Comment { return predicate.CommentPerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.Comment { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Comment { + return predicate.CommentPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Comment { + return predicate.CommentPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Comment { + return predicate.CommentPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Comment { + return predicate.CommentPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // UniqueInt applies equality check predicate on the "unique_int" field. It's identical to UniqueIntEQ. func UniqueInt(v int) predicate.Comment { return predicate.CommentPerDialect( @@ -219,6 +219,50 @@ func UniqueIntNEQ(v int) predicate.Comment { ) } +// UniqueIntIn applies the In predicate on the "unique_int" field. +func UniqueIntIn(vs ...int) predicate.Comment { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CommentPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUniqueInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUniqueInt, p.Within(v...)) + }, + ) +} + +// UniqueIntNotIn applies the NotIn predicate on the "unique_int" field. +func UniqueIntNotIn(vs ...int) predicate.Comment { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CommentPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUniqueInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUniqueInt, p.Without(v...)) + }, + ) +} + // UniqueIntGT applies the GT predicate on the "unique_int" field. func UniqueIntGT(v int) predicate.Comment { return predicate.CommentPerDialect( @@ -267,50 +311,6 @@ func UniqueIntLTE(v int) predicate.Comment { ) } -// UniqueIntIn applies the In predicate on the "unique_int" field. -func UniqueIntIn(vs ...int) predicate.Comment { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CommentPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUniqueInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUniqueInt, p.Within(v...)) - }, - ) -} - -// UniqueIntNotIn applies the NotIn predicate on the "unique_int" field. -func UniqueIntNotIn(vs ...int) predicate.Comment { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CommentPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUniqueInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUniqueInt, p.Without(v...)) - }, - ) -} - // UniqueFloatEQ applies the EQ predicate on the "unique_float" field. func UniqueFloatEQ(v float64) predicate.Comment { return predicate.CommentPerDialect( @@ -335,6 +335,50 @@ func UniqueFloatNEQ(v float64) predicate.Comment { ) } +// UniqueFloatIn applies the In predicate on the "unique_float" field. +func UniqueFloatIn(vs ...float64) predicate.Comment { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CommentPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUniqueFloat), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUniqueFloat, p.Within(v...)) + }, + ) +} + +// UniqueFloatNotIn applies the NotIn predicate on the "unique_float" field. +func UniqueFloatNotIn(vs ...float64) predicate.Comment { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CommentPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUniqueFloat), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUniqueFloat, p.Without(v...)) + }, + ) +} + // UniqueFloatGT applies the GT predicate on the "unique_float" field. func UniqueFloatGT(v float64) predicate.Comment { return predicate.CommentPerDialect( @@ -383,50 +427,6 @@ func UniqueFloatLTE(v float64) predicate.Comment { ) } -// UniqueFloatIn applies the In predicate on the "unique_float" field. -func UniqueFloatIn(vs ...float64) predicate.Comment { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CommentPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUniqueFloat), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUniqueFloat, p.Within(v...)) - }, - ) -} - -// UniqueFloatNotIn applies the NotIn predicate on the "unique_float" field. -func UniqueFloatNotIn(vs ...float64) predicate.Comment { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CommentPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUniqueFloat), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUniqueFloat, p.Without(v...)) - }, - ) -} - // NillableIntEQ applies the EQ predicate on the "nillable_int" field. func NillableIntEQ(v int) predicate.Comment { return predicate.CommentPerDialect( @@ -451,6 +451,50 @@ func NillableIntNEQ(v int) predicate.Comment { ) } +// NillableIntIn applies the In predicate on the "nillable_int" field. +func NillableIntIn(vs ...int) predicate.Comment { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CommentPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNillableInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt, p.Within(v...)) + }, + ) +} + +// NillableIntNotIn applies the NotIn predicate on the "nillable_int" field. +func NillableIntNotIn(vs ...int) predicate.Comment { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.CommentPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNillableInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt, p.Without(v...)) + }, + ) +} + // NillableIntGT applies the GT predicate on the "nillable_int" field. func NillableIntGT(v int) predicate.Comment { return predicate.CommentPerDialect( @@ -499,50 +543,6 @@ func NillableIntLTE(v int) predicate.Comment { ) } -// NillableIntIn applies the In predicate on the "nillable_int" field. -func NillableIntIn(vs ...int) predicate.Comment { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CommentPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNillableInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt, p.Within(v...)) - }, - ) -} - -// NillableIntNotIn applies the NotIn predicate on the "nillable_int" field. -func NillableIntNotIn(vs ...int) predicate.Comment { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.CommentPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNillableInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt, p.Without(v...)) - }, - ) -} - // NillableIntIsNil applies the IsNil predicate on the "nillable_int" field. func NillableIntIsNil() predicate.Comment { return predicate.CommentPerDialect( diff --git a/entc/integration/ent/example_test.go b/entc/integration/ent/example_test.go index cb43bae80..80a7f960c 100644 --- a/entc/integration/ent/example_test.go +++ b/entc/integration/ent/example_test.go @@ -12,6 +12,8 @@ import ( "time" "github.com/facebookincubator/ent/dialect/sql" + + "github.com/facebookincubator/ent/entc/integration/ent/fieldtype" ) // dsn for the database. In order to run the tests locally, run the following command: @@ -104,6 +106,7 @@ func ExampleFieldType() { SetNillableInt32(1). SetNillableInt64(1). SetValidateOptionalInt32(1). + SetState(fieldtype.StateOn). SaveX(ctx) log.Println("fieldtype created:", ft) diff --git a/entc/integration/ent/fieldtype.go b/entc/integration/ent/fieldtype.go index ac7c8f335..c87c0683e 100644 --- a/entc/integration/ent/fieldtype.go +++ b/entc/integration/ent/fieldtype.go @@ -13,6 +13,7 @@ import ( "github.com/facebookincubator/ent/dialect/gremlin" "github.com/facebookincubator/ent/dialect/sql" + "github.com/facebookincubator/ent/entc/integration/ent/fieldtype" ) // FieldType is the model entity for the FieldType schema. @@ -52,6 +53,8 @@ type FieldType struct { NillableInt64 *int64 `json:"nillable_int64,omitempty"` // ValidateOptionalInt32 holds the value of the "validate_optional_int32" field. ValidateOptionalInt32 int32 `json:"validate_optional_int32,omitempty"` + // State holds the value of the "state" field. + State fieldtype.State `json:"state,omitempty"` } // FromRows scans the sql response data into FieldType. @@ -74,6 +77,7 @@ func (ft *FieldType) FromRows(rows *sql.Rows) error { NillableInt32 sql.NullInt64 NillableInt64 sql.NullInt64 ValidateOptionalInt32 sql.NullInt64 + State sql.NullString } // the order here should be the same as in the `fieldtype.Columns`. if err := rows.Scan( @@ -94,6 +98,7 @@ func (ft *FieldType) FromRows(rows *sql.Rows) error { &vft.NillableInt32, &vft.NillableInt64, &vft.ValidateOptionalInt32, + &vft.State, ); err != nil { return err } @@ -129,6 +134,7 @@ func (ft *FieldType) FromRows(rows *sql.Rows) error { *ft.NillableInt64 = vft.NillableInt64.Int64 } ft.ValidateOptionalInt32 = int32(vft.ValidateOptionalInt32.Int64) + ft.State = fieldtype.State(vft.State.String) return nil } @@ -139,23 +145,24 @@ func (ft *FieldType) FromResponse(res *gremlin.Response) error { return err } var vft struct { - ID string `json:"id,omitempty"` - Int int `json:"int,omitempty"` - Int8 int8 `json:"int8,omitempty"` - Int16 int16 `json:"int16,omitempty"` - Int32 int32 `json:"int32,omitempty"` - Int64 int64 `json:"int64,omitempty"` - OptionalInt int `json:"optional_int,omitempty"` - OptionalInt8 int8 `json:"optional_int8,omitempty"` - OptionalInt16 int16 `json:"optional_int16,omitempty"` - OptionalInt32 int32 `json:"optional_int32,omitempty"` - OptionalInt64 int64 `json:"optional_int64,omitempty"` - NillableInt *int `json:"nillable_int,omitempty"` - NillableInt8 *int8 `json:"nillable_int8,omitempty"` - NillableInt16 *int16 `json:"nillable_int16,omitempty"` - NillableInt32 *int32 `json:"nillable_int32,omitempty"` - NillableInt64 *int64 `json:"nillable_int64,omitempty"` - ValidateOptionalInt32 int32 `json:"validate_optional_int32,omitempty"` + ID string `json:"id,omitempty"` + Int int `json:"int,omitempty"` + Int8 int8 `json:"int8,omitempty"` + Int16 int16 `json:"int16,omitempty"` + Int32 int32 `json:"int32,omitempty"` + Int64 int64 `json:"int64,omitempty"` + OptionalInt int `json:"optional_int,omitempty"` + OptionalInt8 int8 `json:"optional_int8,omitempty"` + OptionalInt16 int16 `json:"optional_int16,omitempty"` + OptionalInt32 int32 `json:"optional_int32,omitempty"` + OptionalInt64 int64 `json:"optional_int64,omitempty"` + NillableInt *int `json:"nillable_int,omitempty"` + NillableInt8 *int8 `json:"nillable_int8,omitempty"` + NillableInt16 *int16 `json:"nillable_int16,omitempty"` + NillableInt32 *int32 `json:"nillable_int32,omitempty"` + NillableInt64 *int64 `json:"nillable_int64,omitempty"` + ValidateOptionalInt32 int32 `json:"validate_optional_int32,omitempty"` + State fieldtype.State `json:"state,omitempty"` } if err := vmap.Decode(&vft); err != nil { return err @@ -177,6 +184,7 @@ func (ft *FieldType) FromResponse(res *gremlin.Response) error { ft.NillableInt32 = vft.NillableInt32 ft.NillableInt64 = vft.NillableInt64 ft.ValidateOptionalInt32 = vft.ValidateOptionalInt32 + ft.State = vft.State return nil } @@ -229,6 +237,7 @@ func (ft *FieldType) String() string { buf.WriteString(fmt.Sprintf(", nillable_int64=%v", *v)) } buf.WriteString(fmt.Sprintf(", validate_optional_int32=%v", ft.ValidateOptionalInt32)) + buf.WriteString(fmt.Sprintf(", state=%v", ft.State)) buf.WriteString(")") return buf.String() } @@ -261,23 +270,24 @@ func (ft *FieldTypes) FromResponse(res *gremlin.Response) error { return err } var vft []struct { - ID string `json:"id,omitempty"` - Int int `json:"int,omitempty"` - Int8 int8 `json:"int8,omitempty"` - Int16 int16 `json:"int16,omitempty"` - Int32 int32 `json:"int32,omitempty"` - Int64 int64 `json:"int64,omitempty"` - OptionalInt int `json:"optional_int,omitempty"` - OptionalInt8 int8 `json:"optional_int8,omitempty"` - OptionalInt16 int16 `json:"optional_int16,omitempty"` - OptionalInt32 int32 `json:"optional_int32,omitempty"` - OptionalInt64 int64 `json:"optional_int64,omitempty"` - NillableInt *int `json:"nillable_int,omitempty"` - NillableInt8 *int8 `json:"nillable_int8,omitempty"` - NillableInt16 *int16 `json:"nillable_int16,omitempty"` - NillableInt32 *int32 `json:"nillable_int32,omitempty"` - NillableInt64 *int64 `json:"nillable_int64,omitempty"` - ValidateOptionalInt32 int32 `json:"validate_optional_int32,omitempty"` + ID string `json:"id,omitempty"` + Int int `json:"int,omitempty"` + Int8 int8 `json:"int8,omitempty"` + Int16 int16 `json:"int16,omitempty"` + Int32 int32 `json:"int32,omitempty"` + Int64 int64 `json:"int64,omitempty"` + OptionalInt int `json:"optional_int,omitempty"` + OptionalInt8 int8 `json:"optional_int8,omitempty"` + OptionalInt16 int16 `json:"optional_int16,omitempty"` + OptionalInt32 int32 `json:"optional_int32,omitempty"` + OptionalInt64 int64 `json:"optional_int64,omitempty"` + NillableInt *int `json:"nillable_int,omitempty"` + NillableInt8 *int8 `json:"nillable_int8,omitempty"` + NillableInt16 *int16 `json:"nillable_int16,omitempty"` + NillableInt32 *int32 `json:"nillable_int32,omitempty"` + NillableInt64 *int64 `json:"nillable_int64,omitempty"` + ValidateOptionalInt32 int32 `json:"validate_optional_int32,omitempty"` + State fieldtype.State `json:"state,omitempty"` } if err := vmap.Decode(&vft); err != nil { return err @@ -301,6 +311,7 @@ func (ft *FieldTypes) FromResponse(res *gremlin.Response) error { NillableInt32: v.NillableInt32, NillableInt64: v.NillableInt64, ValidateOptionalInt32: v.ValidateOptionalInt32, + State: v.State, }) } return nil diff --git a/entc/integration/ent/fieldtype/fieldtype.go b/entc/integration/ent/fieldtype/fieldtype.go index 0a4c89405..472f74906 100644 --- a/entc/integration/ent/fieldtype/fieldtype.go +++ b/entc/integration/ent/fieldtype/fieldtype.go @@ -7,6 +7,8 @@ package fieldtype import ( + "fmt" + "github.com/facebookincubator/ent/entc/integration/ent/schema" ) @@ -47,6 +49,8 @@ const ( FieldNillableInt64 = "nillable_int64" // FieldValidateOptionalInt32 holds the string denoting the validate_optional_int32 vertex property in the database. FieldValidateOptionalInt32 = "validate_optional_int32" + // FieldState holds the string denoting the state vertex property in the database. + FieldState = "state" // Table holds the table name of the fieldtype in the database. Table = "field_types" @@ -71,6 +75,7 @@ var Columns = []string{ FieldNillableInt32, FieldNillableInt64, FieldValidateOptionalInt32, + FieldState, } var ( @@ -81,3 +86,25 @@ var ( // ValidateOptionalInt32Validator is a validator for the "validate_optional_int32" field. It is called by the builders before save. ValidateOptionalInt32Validator = descValidateOptionalInt32.Validators[0].(func(int32) error) ) + +// State defines the type for the state enum field. +type State string + +const ( + StateOn State = "on" + StateOff State = "off" +) + +func (s State) String() string { + return string(s) +} + +// StateValidator is a validator for the "state" field enum values. It is called by the builders before save. +func StateValidator(state State) error { + switch state { + case StateOn, StateOff: + return nil + default: + return fmt.Errorf("fieldtype: invalid enum value for state field: %q", state) + } +} diff --git a/entc/integration/ent/fieldtype/where.go b/entc/integration/ent/fieldtype/where.go index 8fcecf271..3726e2700 100644 --- a/entc/integration/ent/fieldtype/where.go +++ b/entc/integration/ent/fieldtype/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.FieldType { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.FieldType { - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.FieldType { - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.FieldType { - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.FieldType { - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.FieldType { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Int applies equality check predicate on the "int" field. It's identical to IntEQ. func Int(v int) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -375,6 +375,50 @@ func IntNEQ(v int) predicate.FieldType { ) } +// IntIn applies the In predicate on the "int" field. +func IntIn(vs ...int) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt, p.Within(v...)) + }, + ) +} + +// IntNotIn applies the NotIn predicate on the "int" field. +func IntNotIn(vs ...int) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt, p.Without(v...)) + }, + ) +} + // IntGT applies the GT predicate on the "int" field. func IntGT(v int) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -423,50 +467,6 @@ func IntLTE(v int) predicate.FieldType { ) } -// IntIn applies the In predicate on the "int" field. -func IntIn(vs ...int) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt, p.Within(v...)) - }, - ) -} - -// IntNotIn applies the NotIn predicate on the "int" field. -func IntNotIn(vs ...int) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt, p.Without(v...)) - }, - ) -} - // Int8EQ applies the EQ predicate on the "int8" field. func Int8EQ(v int8) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -491,6 +491,50 @@ func Int8NEQ(v int8) predicate.FieldType { ) } +// Int8In applies the In predicate on the "int8" field. +func Int8In(vs ...int8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldInt8), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt8, p.Within(v...)) + }, + ) +} + +// Int8NotIn applies the NotIn predicate on the "int8" field. +func Int8NotIn(vs ...int8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldInt8), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt8, p.Without(v...)) + }, + ) +} + // Int8GT applies the GT predicate on the "int8" field. func Int8GT(v int8) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -539,50 +583,6 @@ func Int8LTE(v int8) predicate.FieldType { ) } -// Int8In applies the In predicate on the "int8" field. -func Int8In(vs ...int8) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldInt8), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt8, p.Within(v...)) - }, - ) -} - -// Int8NotIn applies the NotIn predicate on the "int8" field. -func Int8NotIn(vs ...int8) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldInt8), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt8, p.Without(v...)) - }, - ) -} - // Int16EQ applies the EQ predicate on the "int16" field. func Int16EQ(v int16) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -607,6 +607,50 @@ func Int16NEQ(v int16) predicate.FieldType { ) } +// Int16In applies the In predicate on the "int16" field. +func Int16In(vs ...int16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldInt16), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt16, p.Within(v...)) + }, + ) +} + +// Int16NotIn applies the NotIn predicate on the "int16" field. +func Int16NotIn(vs ...int16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldInt16), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt16, p.Without(v...)) + }, + ) +} + // Int16GT applies the GT predicate on the "int16" field. func Int16GT(v int16) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -655,50 +699,6 @@ func Int16LTE(v int16) predicate.FieldType { ) } -// Int16In applies the In predicate on the "int16" field. -func Int16In(vs ...int16) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldInt16), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt16, p.Within(v...)) - }, - ) -} - -// Int16NotIn applies the NotIn predicate on the "int16" field. -func Int16NotIn(vs ...int16) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldInt16), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt16, p.Without(v...)) - }, - ) -} - // Int32EQ applies the EQ predicate on the "int32" field. func Int32EQ(v int32) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -723,6 +723,50 @@ func Int32NEQ(v int32) predicate.FieldType { ) } +// Int32In applies the In predicate on the "int32" field. +func Int32In(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt32, p.Within(v...)) + }, + ) +} + +// Int32NotIn applies the NotIn predicate on the "int32" field. +func Int32NotIn(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt32, p.Without(v...)) + }, + ) +} + // Int32GT applies the GT predicate on the "int32" field. func Int32GT(v int32) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -771,50 +815,6 @@ func Int32LTE(v int32) predicate.FieldType { ) } -// Int32In applies the In predicate on the "int32" field. -func Int32In(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt32, p.Within(v...)) - }, - ) -} - -// Int32NotIn applies the NotIn predicate on the "int32" field. -func Int32NotIn(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt32, p.Without(v...)) - }, - ) -} - // Int64EQ applies the EQ predicate on the "int64" field. func Int64EQ(v int64) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -839,6 +839,50 @@ func Int64NEQ(v int64) predicate.FieldType { ) } +// Int64In applies the In predicate on the "int64" field. +func Int64In(vs ...int64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldInt64), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt64, p.Within(v...)) + }, + ) +} + +// Int64NotIn applies the NotIn predicate on the "int64" field. +func Int64NotIn(vs ...int64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldInt64), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldInt64, p.Without(v...)) + }, + ) +} + // Int64GT applies the GT predicate on the "int64" field. func Int64GT(v int64) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -887,50 +931,6 @@ func Int64LTE(v int64) predicate.FieldType { ) } -// Int64In applies the In predicate on the "int64" field. -func Int64In(vs ...int64) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldInt64), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt64, p.Within(v...)) - }, - ) -} - -// Int64NotIn applies the NotIn predicate on the "int64" field. -func Int64NotIn(vs ...int64) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldInt64), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldInt64, p.Without(v...)) - }, - ) -} - // OptionalIntEQ applies the EQ predicate on the "optional_int" field. func OptionalIntEQ(v int) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -955,6 +955,50 @@ func OptionalIntNEQ(v int) predicate.FieldType { ) } +// OptionalIntIn applies the In predicate on the "optional_int" field. +func OptionalIntIn(vs ...int) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt, p.Within(v...)) + }, + ) +} + +// OptionalIntNotIn applies the NotIn predicate on the "optional_int" field. +func OptionalIntNotIn(vs ...int) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt, p.Without(v...)) + }, + ) +} + // OptionalIntGT applies the GT predicate on the "optional_int" field. func OptionalIntGT(v int) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1003,50 +1047,6 @@ func OptionalIntLTE(v int) predicate.FieldType { ) } -// OptionalIntIn applies the In predicate on the "optional_int" field. -func OptionalIntIn(vs ...int) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldOptionalInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt, p.Within(v...)) - }, - ) -} - -// OptionalIntNotIn applies the NotIn predicate on the "optional_int" field. -func OptionalIntNotIn(vs ...int) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldOptionalInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt, p.Without(v...)) - }, - ) -} - // OptionalIntIsNil applies the IsNil predicate on the "optional_int" field. func OptionalIntIsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1095,6 +1095,50 @@ func OptionalInt8NEQ(v int8) predicate.FieldType { ) } +// OptionalInt8In applies the In predicate on the "optional_int8" field. +func OptionalInt8In(vs ...int8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalInt8), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt8, p.Within(v...)) + }, + ) +} + +// OptionalInt8NotIn applies the NotIn predicate on the "optional_int8" field. +func OptionalInt8NotIn(vs ...int8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalInt8), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt8, p.Without(v...)) + }, + ) +} + // OptionalInt8GT applies the GT predicate on the "optional_int8" field. func OptionalInt8GT(v int8) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1143,50 +1187,6 @@ func OptionalInt8LTE(v int8) predicate.FieldType { ) } -// OptionalInt8In applies the In predicate on the "optional_int8" field. -func OptionalInt8In(vs ...int8) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldOptionalInt8), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt8, p.Within(v...)) - }, - ) -} - -// OptionalInt8NotIn applies the NotIn predicate on the "optional_int8" field. -func OptionalInt8NotIn(vs ...int8) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldOptionalInt8), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt8, p.Without(v...)) - }, - ) -} - // OptionalInt8IsNil applies the IsNil predicate on the "optional_int8" field. func OptionalInt8IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1235,6 +1235,50 @@ func OptionalInt16NEQ(v int16) predicate.FieldType { ) } +// OptionalInt16In applies the In predicate on the "optional_int16" field. +func OptionalInt16In(vs ...int16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalInt16), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt16, p.Within(v...)) + }, + ) +} + +// OptionalInt16NotIn applies the NotIn predicate on the "optional_int16" field. +func OptionalInt16NotIn(vs ...int16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalInt16), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt16, p.Without(v...)) + }, + ) +} + // OptionalInt16GT applies the GT predicate on the "optional_int16" field. func OptionalInt16GT(v int16) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1283,50 +1327,6 @@ func OptionalInt16LTE(v int16) predicate.FieldType { ) } -// OptionalInt16In applies the In predicate on the "optional_int16" field. -func OptionalInt16In(vs ...int16) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldOptionalInt16), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt16, p.Within(v...)) - }, - ) -} - -// OptionalInt16NotIn applies the NotIn predicate on the "optional_int16" field. -func OptionalInt16NotIn(vs ...int16) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldOptionalInt16), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt16, p.Without(v...)) - }, - ) -} - // OptionalInt16IsNil applies the IsNil predicate on the "optional_int16" field. func OptionalInt16IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1375,6 +1375,50 @@ func OptionalInt32NEQ(v int32) predicate.FieldType { ) } +// OptionalInt32In applies the In predicate on the "optional_int32" field. +func OptionalInt32In(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt32, p.Within(v...)) + }, + ) +} + +// OptionalInt32NotIn applies the NotIn predicate on the "optional_int32" field. +func OptionalInt32NotIn(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt32, p.Without(v...)) + }, + ) +} + // OptionalInt32GT applies the GT predicate on the "optional_int32" field. func OptionalInt32GT(v int32) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1423,50 +1467,6 @@ func OptionalInt32LTE(v int32) predicate.FieldType { ) } -// OptionalInt32In applies the In predicate on the "optional_int32" field. -func OptionalInt32In(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldOptionalInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt32, p.Within(v...)) - }, - ) -} - -// OptionalInt32NotIn applies the NotIn predicate on the "optional_int32" field. -func OptionalInt32NotIn(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldOptionalInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt32, p.Without(v...)) - }, - ) -} - // OptionalInt32IsNil applies the IsNil predicate on the "optional_int32" field. func OptionalInt32IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1515,6 +1515,50 @@ func OptionalInt64NEQ(v int64) predicate.FieldType { ) } +// OptionalInt64In applies the In predicate on the "optional_int64" field. +func OptionalInt64In(vs ...int64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalInt64), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt64, p.Within(v...)) + }, + ) +} + +// OptionalInt64NotIn applies the NotIn predicate on the "optional_int64" field. +func OptionalInt64NotIn(vs ...int64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalInt64), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldOptionalInt64, p.Without(v...)) + }, + ) +} + // OptionalInt64GT applies the GT predicate on the "optional_int64" field. func OptionalInt64GT(v int64) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1563,50 +1607,6 @@ func OptionalInt64LTE(v int64) predicate.FieldType { ) } -// OptionalInt64In applies the In predicate on the "optional_int64" field. -func OptionalInt64In(vs ...int64) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldOptionalInt64), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt64, p.Within(v...)) - }, - ) -} - -// OptionalInt64NotIn applies the NotIn predicate on the "optional_int64" field. -func OptionalInt64NotIn(vs ...int64) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldOptionalInt64), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldOptionalInt64, p.Without(v...)) - }, - ) -} - // OptionalInt64IsNil applies the IsNil predicate on the "optional_int64" field. func OptionalInt64IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1655,6 +1655,50 @@ func NillableIntNEQ(v int) predicate.FieldType { ) } +// NillableIntIn applies the In predicate on the "nillable_int" field. +func NillableIntIn(vs ...int) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNillableInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt, p.Within(v...)) + }, + ) +} + +// NillableIntNotIn applies the NotIn predicate on the "nillable_int" field. +func NillableIntNotIn(vs ...int) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNillableInt), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt, p.Without(v...)) + }, + ) +} + // NillableIntGT applies the GT predicate on the "nillable_int" field. func NillableIntGT(v int) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1703,50 +1747,6 @@ func NillableIntLTE(v int) predicate.FieldType { ) } -// NillableIntIn applies the In predicate on the "nillable_int" field. -func NillableIntIn(vs ...int) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNillableInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt, p.Within(v...)) - }, - ) -} - -// NillableIntNotIn applies the NotIn predicate on the "nillable_int" field. -func NillableIntNotIn(vs ...int) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNillableInt), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt, p.Without(v...)) - }, - ) -} - // NillableIntIsNil applies the IsNil predicate on the "nillable_int" field. func NillableIntIsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1795,6 +1795,50 @@ func NillableInt8NEQ(v int8) predicate.FieldType { ) } +// NillableInt8In applies the In predicate on the "nillable_int8" field. +func NillableInt8In(vs ...int8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNillableInt8), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt8, p.Within(v...)) + }, + ) +} + +// NillableInt8NotIn applies the NotIn predicate on the "nillable_int8" field. +func NillableInt8NotIn(vs ...int8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNillableInt8), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt8, p.Without(v...)) + }, + ) +} + // NillableInt8GT applies the GT predicate on the "nillable_int8" field. func NillableInt8GT(v int8) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1843,50 +1887,6 @@ func NillableInt8LTE(v int8) predicate.FieldType { ) } -// NillableInt8In applies the In predicate on the "nillable_int8" field. -func NillableInt8In(vs ...int8) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNillableInt8), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt8, p.Within(v...)) - }, - ) -} - -// NillableInt8NotIn applies the NotIn predicate on the "nillable_int8" field. -func NillableInt8NotIn(vs ...int8) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNillableInt8), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt8, p.Without(v...)) - }, - ) -} - // NillableInt8IsNil applies the IsNil predicate on the "nillable_int8" field. func NillableInt8IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1935,6 +1935,50 @@ func NillableInt16NEQ(v int16) predicate.FieldType { ) } +// NillableInt16In applies the In predicate on the "nillable_int16" field. +func NillableInt16In(vs ...int16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNillableInt16), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt16, p.Within(v...)) + }, + ) +} + +// NillableInt16NotIn applies the NotIn predicate on the "nillable_int16" field. +func NillableInt16NotIn(vs ...int16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNillableInt16), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt16, p.Without(v...)) + }, + ) +} + // NillableInt16GT applies the GT predicate on the "nillable_int16" field. func NillableInt16GT(v int16) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -1983,50 +2027,6 @@ func NillableInt16LTE(v int16) predicate.FieldType { ) } -// NillableInt16In applies the In predicate on the "nillable_int16" field. -func NillableInt16In(vs ...int16) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNillableInt16), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt16, p.Within(v...)) - }, - ) -} - -// NillableInt16NotIn applies the NotIn predicate on the "nillable_int16" field. -func NillableInt16NotIn(vs ...int16) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNillableInt16), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt16, p.Without(v...)) - }, - ) -} - // NillableInt16IsNil applies the IsNil predicate on the "nillable_int16" field. func NillableInt16IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2075,6 +2075,50 @@ func NillableInt32NEQ(v int32) predicate.FieldType { ) } +// NillableInt32In applies the In predicate on the "nillable_int32" field. +func NillableInt32In(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNillableInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt32, p.Within(v...)) + }, + ) +} + +// NillableInt32NotIn applies the NotIn predicate on the "nillable_int32" field. +func NillableInt32NotIn(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNillableInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt32, p.Without(v...)) + }, + ) +} + // NillableInt32GT applies the GT predicate on the "nillable_int32" field. func NillableInt32GT(v int32) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2123,50 +2167,6 @@ func NillableInt32LTE(v int32) predicate.FieldType { ) } -// NillableInt32In applies the In predicate on the "nillable_int32" field. -func NillableInt32In(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNillableInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt32, p.Within(v...)) - }, - ) -} - -// NillableInt32NotIn applies the NotIn predicate on the "nillable_int32" field. -func NillableInt32NotIn(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNillableInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt32, p.Without(v...)) - }, - ) -} - // NillableInt32IsNil applies the IsNil predicate on the "nillable_int32" field. func NillableInt32IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2215,6 +2215,50 @@ func NillableInt64NEQ(v int64) predicate.FieldType { ) } +// NillableInt64In applies the In predicate on the "nillable_int64" field. +func NillableInt64In(vs ...int64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNillableInt64), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt64, p.Within(v...)) + }, + ) +} + +// NillableInt64NotIn applies the NotIn predicate on the "nillable_int64" field. +func NillableInt64NotIn(vs ...int64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNillableInt64), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNillableInt64, p.Without(v...)) + }, + ) +} + // NillableInt64GT applies the GT predicate on the "nillable_int64" field. func NillableInt64GT(v int64) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2263,50 +2307,6 @@ func NillableInt64LTE(v int64) predicate.FieldType { ) } -// NillableInt64In applies the In predicate on the "nillable_int64" field. -func NillableInt64In(vs ...int64) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNillableInt64), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt64, p.Within(v...)) - }, - ) -} - -// NillableInt64NotIn applies the NotIn predicate on the "nillable_int64" field. -func NillableInt64NotIn(vs ...int64) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNillableInt64), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNillableInt64, p.Without(v...)) - }, - ) -} - // NillableInt64IsNil applies the IsNil predicate on the "nillable_int64" field. func NillableInt64IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2355,6 +2355,50 @@ func ValidateOptionalInt32NEQ(v int32) predicate.FieldType { ) } +// ValidateOptionalInt32In applies the In predicate on the "validate_optional_int32" field. +func ValidateOptionalInt32In(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldValidateOptionalInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldValidateOptionalInt32, p.Within(v...)) + }, + ) +} + +// ValidateOptionalInt32NotIn applies the NotIn predicate on the "validate_optional_int32" field. +func ValidateOptionalInt32NotIn(vs ...int32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldValidateOptionalInt32), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldValidateOptionalInt32, p.Without(v...)) + }, + ) +} + // ValidateOptionalInt32GT applies the GT predicate on the "validate_optional_int32" field. func ValidateOptionalInt32GT(v int32) predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2403,50 +2447,6 @@ func ValidateOptionalInt32LTE(v int32) predicate.FieldType { ) } -// ValidateOptionalInt32In applies the In predicate on the "validate_optional_int32" field. -func ValidateOptionalInt32In(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldValidateOptionalInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldValidateOptionalInt32, p.Within(v...)) - }, - ) -} - -// ValidateOptionalInt32NotIn applies the NotIn predicate on the "validate_optional_int32" field. -func ValidateOptionalInt32NotIn(vs ...int32) predicate.FieldType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FieldTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldValidateOptionalInt32), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldValidateOptionalInt32, p.Without(v...)) - }, - ) -} - // ValidateOptionalInt32IsNil applies the IsNil predicate on the "validate_optional_int32" field. func ValidateOptionalInt32IsNil() predicate.FieldType { return predicate.FieldTypePerDialect( @@ -2471,6 +2471,98 @@ func ValidateOptionalInt32NotNil() predicate.FieldType { ) } +// StateEQ applies the EQ predicate on the "state" field. +func StateEQ(v State) predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldState), v)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldState, p.EQ(v)) + }, + ) +} + +// StateNEQ applies the NEQ predicate on the "state" field. +func StateNEQ(v State) predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldState), v)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldState, p.NEQ(v)) + }, + ) +} + +// StateIn applies the In predicate on the "state" field. +func StateIn(vs ...State) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldState), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldState, p.Within(v...)) + }, + ) +} + +// StateNotIn applies the NotIn predicate on the "state" field. +func StateNotIn(vs ...State) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldState), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldState, p.Without(v...)) + }, + ) +} + +// StateIsNil applies the IsNil predicate on the "state" field. +func StateIsNil() predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldState))) + }, + func(t *dsl.Traversal) { + t.HasLabel(Label).HasNot(FieldState) + }, + ) +} + +// StateNotNil applies the NotNil predicate on the "state" field. +func StateNotNil() predicate.FieldType { + return predicate.FieldTypePerDialect( + func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldState))) + }, + func(t *dsl.Traversal) { + t.HasLabel(Label).Has(FieldState) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.FieldType) predicate.FieldType { return predicate.FieldTypePerDialect( diff --git a/entc/integration/ent/fieldtype_create.go b/entc/integration/ent/fieldtype_create.go index 78a775503..65efb08f4 100644 --- a/entc/integration/ent/fieldtype_create.go +++ b/entc/integration/ent/fieldtype_create.go @@ -39,6 +39,7 @@ type FieldTypeCreate struct { nillable_int32 *int32 nillable_int64 *int64 validate_optional_int32 *int32 + state *fieldtype.State } // SetInt sets the int field. @@ -225,6 +226,20 @@ func (ftc *FieldTypeCreate) SetNillableValidateOptionalInt32(i *int32) *FieldTyp return ftc } +// SetState sets the state field. +func (ftc *FieldTypeCreate) SetState(f fieldtype.State) *FieldTypeCreate { + ftc.state = &f + return ftc +} + +// SetNillableState sets the state field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableState(f *fieldtype.State) *FieldTypeCreate { + if f != nil { + ftc.SetState(*f) + } + return ftc +} + // Save creates the FieldType in the database. func (ftc *FieldTypeCreate) Save(ctx context.Context) (*FieldType, error) { if ftc.int == nil { @@ -247,6 +262,11 @@ func (ftc *FieldTypeCreate) Save(ctx context.Context) (*FieldType, error) { return nil, fmt.Errorf("ent: validator failed for field \"validate_optional_int32\": %v", err) } } + if ftc.state != nil { + if err := fieldtype.StateValidator(*ftc.state); err != nil { + return nil, fmt.Errorf("ent: validator failed for field \"state\": %v", err) + } + } switch ftc.driver.Dialect() { case dialect.MySQL, dialect.SQLite: return ftc.sqlSave(ctx) @@ -340,6 +360,10 @@ func (ftc *FieldTypeCreate) sqlSave(ctx context.Context) (*FieldType, error) { builder.Set(fieldtype.FieldValidateOptionalInt32, *value) ft.ValidateOptionalInt32 = *value } + if value := ftc.state; value != nil { + builder.Set(fieldtype.FieldState, *value) + ft.State = *value + } query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { return nil, rollback(tx, err) @@ -421,5 +445,8 @@ func (ftc *FieldTypeCreate) gremlin() *dsl.Traversal { if ftc.validate_optional_int32 != nil { v.Property(dsl.Single, fieldtype.FieldValidateOptionalInt32, *ftc.validate_optional_int32) } + if ftc.state != nil { + v.Property(dsl.Single, fieldtype.FieldState, *ftc.state) + } return v.ValueMap(true) } diff --git a/entc/integration/ent/fieldtype_update.go b/entc/integration/ent/fieldtype_update.go index f2139dca4..185f1adfe 100644 --- a/entc/integration/ent/fieldtype_update.go +++ b/entc/integration/ent/fieldtype_update.go @@ -67,6 +67,8 @@ type FieldTypeUpdate struct { validate_optional_int32 *int32 addvalidate_optional_int32 *int32 clearvalidate_optional_int32 bool + state *fieldtype.State + clearstate bool predicates []predicate.FieldType } @@ -513,6 +515,27 @@ func (ftu *FieldTypeUpdate) ClearValidateOptionalInt32() *FieldTypeUpdate { return ftu } +// SetState sets the state field. +func (ftu *FieldTypeUpdate) SetState(f fieldtype.State) *FieldTypeUpdate { + ftu.state = &f + return ftu +} + +// SetNillableState sets the state field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableState(f *fieldtype.State) *FieldTypeUpdate { + if f != nil { + ftu.SetState(*f) + } + return ftu +} + +// ClearState clears the value of state. +func (ftu *FieldTypeUpdate) ClearState() *FieldTypeUpdate { + ftu.state = nil + ftu.clearstate = true + 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 ftu.validate_optional_int32 != nil { @@ -520,6 +543,11 @@ func (ftu *FieldTypeUpdate) Save(ctx context.Context) (int, error) { return 0, fmt.Errorf("ent: validator failed for field \"validate_optional_int32\": %v", err) } } + if ftu.state != nil { + if err := fieldtype.StateValidator(*ftu.state); err != nil { + return 0, fmt.Errorf("ent: validator failed for field \"state\": %v", err) + } + } switch ftu.driver.Dialect() { case dialect.MySQL, dialect.SQLite: return ftu.sqlSave(ctx) @@ -712,6 +740,12 @@ func (ftu *FieldTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { if ftu.clearvalidate_optional_int32 { builder.SetNull(fieldtype.FieldValidateOptionalInt32) } + if value := ftu.state; value != nil { + builder.Set(fieldtype.FieldState, *value) + } + if ftu.clearstate { + builder.SetNull(fieldtype.FieldState) + } if !builder.Empty() { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { @@ -840,6 +874,9 @@ func (ftu *FieldTypeUpdate) gremlin() *dsl.Traversal { if value := ftu.addvalidate_optional_int32; value != nil { v.Property(dsl.Single, fieldtype.FieldValidateOptionalInt32, __.Union(__.Values(fieldtype.FieldValidateOptionalInt32), __.Constant(*value)).Sum()) } + if value := ftu.state; value != nil { + v.Property(dsl.Single, fieldtype.FieldState, *value) + } var properties []interface{} if ftu.clearoptional_int { properties = append(properties, fieldtype.FieldOptionalInt) @@ -874,6 +911,9 @@ func (ftu *FieldTypeUpdate) gremlin() *dsl.Traversal { if ftu.clearvalidate_optional_int32 { properties = append(properties, fieldtype.FieldValidateOptionalInt32) } + if ftu.clearstate { + properties = append(properties, fieldtype.FieldState) + } if len(properties) > 0 { v.SideEffect(__.Properties(properties...).Drop()) } @@ -929,6 +969,8 @@ type FieldTypeUpdateOne struct { validate_optional_int32 *int32 addvalidate_optional_int32 *int32 clearvalidate_optional_int32 bool + state *fieldtype.State + clearstate bool } // SetInt sets the int field. @@ -1368,6 +1410,27 @@ func (ftuo *FieldTypeUpdateOne) ClearValidateOptionalInt32() *FieldTypeUpdateOne return ftuo } +// SetState sets the state field. +func (ftuo *FieldTypeUpdateOne) SetState(f fieldtype.State) *FieldTypeUpdateOne { + ftuo.state = &f + return ftuo +} + +// SetNillableState sets the state field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableState(f *fieldtype.State) *FieldTypeUpdateOne { + if f != nil { + ftuo.SetState(*f) + } + return ftuo +} + +// ClearState clears the value of state. +func (ftuo *FieldTypeUpdateOne) ClearState() *FieldTypeUpdateOne { + ftuo.state = nil + ftuo.clearstate = true + return ftuo +} + // Save executes the query and returns the updated entity. func (ftuo *FieldTypeUpdateOne) Save(ctx context.Context) (*FieldType, error) { if ftuo.validate_optional_int32 != nil { @@ -1375,6 +1438,11 @@ func (ftuo *FieldTypeUpdateOne) Save(ctx context.Context) (*FieldType, error) { return nil, fmt.Errorf("ent: validator failed for field \"validate_optional_int32\": %v", err) } } + if ftuo.state != nil { + if err := fieldtype.StateValidator(*ftuo.state); err != nil { + return nil, fmt.Errorf("ent: validator failed for field \"state\": %v", err) + } + } switch ftuo.driver.Dialect() { case dialect.MySQL, dialect.SQLite: return ftuo.sqlSave(ctx) @@ -1639,6 +1707,15 @@ func (ftuo *FieldTypeUpdateOne) sqlSave(ctx context.Context) (ft *FieldType, err ft.ValidateOptionalInt32 = value builder.SetNull(fieldtype.FieldValidateOptionalInt32) } + if value := ftuo.state; value != nil { + builder.Set(fieldtype.FieldState, *value) + ft.State = *value + } + if ftuo.clearstate { + var value fieldtype.State + ft.State = value + builder.SetNull(fieldtype.FieldState) + } if !builder.Empty() { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { @@ -1768,6 +1845,9 @@ func (ftuo *FieldTypeUpdateOne) gremlin(id string) *dsl.Traversal { if value := ftuo.addvalidate_optional_int32; value != nil { v.Property(dsl.Single, fieldtype.FieldValidateOptionalInt32, __.Union(__.Values(fieldtype.FieldValidateOptionalInt32), __.Constant(*value)).Sum()) } + if value := ftuo.state; value != nil { + v.Property(dsl.Single, fieldtype.FieldState, *value) + } var properties []interface{} if ftuo.clearoptional_int { properties = append(properties, fieldtype.FieldOptionalInt) @@ -1802,6 +1882,9 @@ func (ftuo *FieldTypeUpdateOne) gremlin(id string) *dsl.Traversal { if ftuo.clearvalidate_optional_int32 { properties = append(properties, fieldtype.FieldValidateOptionalInt32) } + if ftuo.clearstate { + properties = append(properties, fieldtype.FieldState) + } if len(properties) > 0 { v.SideEffect(__.Properties(properties...).Drop()) } diff --git a/entc/integration/ent/file/where.go b/entc/integration/ent/file/where.go index e40983803..778016cc0 100644 --- a/entc/integration/ent/file/where.go +++ b/entc/integration/ent/file/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.File { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.File { return predicate.FilePerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.File { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.File { + return predicate.FilePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.File { + return predicate.FilePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.File { + return predicate.FilePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.File { + return predicate.FilePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Size applies equality check predicate on the "size" field. It's identical to SizeEQ. func Size(v int) predicate.File { return predicate.FilePerDialect( @@ -231,6 +231,50 @@ func SizeNEQ(v int) predicate.File { ) } +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...int) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldSize), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldSize, p.Within(v...)) + }, + ) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...int) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldSize), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldSize, p.Without(v...)) + }, + ) +} + // SizeGT applies the GT predicate on the "size" field. func SizeGT(v int) predicate.File { return predicate.FilePerDialect( @@ -279,50 +323,6 @@ func SizeLTE(v int) predicate.File { ) } -// SizeIn applies the In predicate on the "size" field. -func SizeIn(vs ...int) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldSize), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldSize, p.Within(v...)) - }, - ) -} - -// SizeNotIn applies the NotIn predicate on the "size" field. -func SizeNotIn(vs ...int) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldSize), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldSize, p.Without(v...)) - }, - ) -} - // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.File { return predicate.FilePerDialect( @@ -347,6 +347,50 @@ func NameNEQ(v string) predicate.File { ) } +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Within(v...)) + }, + ) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Without(v...)) + }, + ) +} + // NameGT applies the GT predicate on the "name" field. func NameGT(v string) predicate.File { return predicate.FilePerDialect( @@ -395,50 +439,6 @@ func NameLTE(v string) predicate.File { ) } -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Within(v...)) - }, - ) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Without(v...)) - }, - ) -} - // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.File { return predicate.FilePerDialect( @@ -499,6 +499,50 @@ func UserNEQ(v string) predicate.File { ) } +// UserIn applies the In predicate on the "user" field. +func UserIn(vs ...string) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldUser), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUser, p.Within(v...)) + }, + ) +} + +// UserNotIn applies the NotIn predicate on the "user" field. +func UserNotIn(vs ...string) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldUser), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldUser, p.Without(v...)) + }, + ) +} + // UserGT applies the GT predicate on the "user" field. func UserGT(v string) predicate.File { return predicate.FilePerDialect( @@ -547,50 +591,6 @@ func UserLTE(v string) predicate.File { ) } -// UserIn applies the In predicate on the "user" field. -func UserIn(vs ...string) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUser), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUser, p.Within(v...)) - }, - ) -} - -// UserNotIn applies the NotIn predicate on the "user" field. -func UserNotIn(vs ...string) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUser), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldUser, p.Without(v...)) - }, - ) -} - // UserContains applies the Contains predicate on the "user" field. func UserContains(v string) predicate.File { return predicate.FilePerDialect( @@ -675,6 +675,50 @@ func GroupNEQ(v string) predicate.File { ) } +// GroupIn applies the In predicate on the "group" field. +func GroupIn(vs ...string) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldGroup), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldGroup, p.Within(v...)) + }, + ) +} + +// GroupNotIn applies the NotIn predicate on the "group" field. +func GroupNotIn(vs ...string) predicate.File { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FilePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldGroup), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldGroup, p.Without(v...)) + }, + ) +} + // GroupGT applies the GT predicate on the "group" field. func GroupGT(v string) predicate.File { return predicate.FilePerDialect( @@ -723,50 +767,6 @@ func GroupLTE(v string) predicate.File { ) } -// GroupIn applies the In predicate on the "group" field. -func GroupIn(vs ...string) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldGroup), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldGroup, p.Within(v...)) - }, - ) -} - -// GroupNotIn applies the NotIn predicate on the "group" field. -func GroupNotIn(vs ...string) predicate.File { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FilePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldGroup), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldGroup, p.Without(v...)) - }, - ) -} - // GroupContains applies the Contains predicate on the "group" field. func GroupContains(v string) predicate.File { return predicate.FilePerDialect( diff --git a/entc/integration/ent/filetype/where.go b/entc/integration/ent/filetype/where.go index 379254b1d..d0059cba8 100644 --- a/entc/integration/ent/filetype/where.go +++ b/entc/integration/ent/filetype/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.FileType { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.FileType { - return predicate.FileTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.FileType { - return predicate.FileTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.FileType { - return predicate.FileTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.FileType { - return predicate.FileTypePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.FileType { return predicate.FileTypePerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.FileType { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.FileType { + return predicate.FileTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.FileType { + return predicate.FileTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.FileType { + return predicate.FileTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.FileType { + return predicate.FileTypePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.FileType { return predicate.FileTypePerDialect( @@ -195,6 +195,50 @@ func NameNEQ(v string) predicate.FileType { ) } +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.FileType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FileTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Within(v...)) + }, + ) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.FileType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FileTypePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Without(v...)) + }, + ) +} + // NameGT applies the GT predicate on the "name" field. func NameGT(v string) predicate.FileType { return predicate.FileTypePerDialect( @@ -243,50 +287,6 @@ func NameLTE(v string) predicate.FileType { ) } -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.FileType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FileTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Within(v...)) - }, - ) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.FileType { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.FileTypePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Without(v...)) - }, - ) -} - // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.FileType { return predicate.FileTypePerDialect( diff --git a/entc/integration/ent/group/where.go b/entc/integration/ent/group/where.go index cbf38356e..492fbbb7a 100644 --- a/entc/integration/ent/group/where.go +++ b/entc/integration/ent/group/where.go @@ -56,58 +56,6 @@ func IDNEQ(id string) predicate.Group { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.Group { - return predicate.GroupPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.Group { - return predicate.GroupPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.Group { - return predicate.GroupPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.Group { - return predicate.GroupPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.Group { return predicate.GroupPerDialect( @@ -160,6 +108,58 @@ func IDNotIn(ids ...string) predicate.Group { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Group { + return predicate.GroupPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Group { + return predicate.GroupPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Group { + return predicate.GroupPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Group { + return predicate.GroupPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Active applies equality check predicate on the "active" field. It's identical to ActiveEQ. func Active(v bool) predicate.Group { return predicate.GroupPerDialect( @@ -268,6 +268,50 @@ func ExpireNEQ(v time.Time) predicate.Group { ) } +// ExpireIn applies the In predicate on the "expire" field. +func ExpireIn(vs ...time.Time) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldExpire), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldExpire, p.Within(v...)) + }, + ) +} + +// ExpireNotIn applies the NotIn predicate on the "expire" field. +func ExpireNotIn(vs ...time.Time) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldExpire), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldExpire, p.Without(v...)) + }, + ) +} + // ExpireGT applies the GT predicate on the "expire" field. func ExpireGT(v time.Time) predicate.Group { return predicate.GroupPerDialect( @@ -316,50 +360,6 @@ func ExpireLTE(v time.Time) predicate.Group { ) } -// ExpireIn applies the In predicate on the "expire" field. -func ExpireIn(vs ...time.Time) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldExpire), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldExpire, p.Within(v...)) - }, - ) -} - -// ExpireNotIn applies the NotIn predicate on the "expire" field. -func ExpireNotIn(vs ...time.Time) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldExpire), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldExpire, p.Without(v...)) - }, - ) -} - // TypeEQ applies the EQ predicate on the "type" field. func TypeEQ(v string) predicate.Group { return predicate.GroupPerDialect( @@ -384,6 +384,50 @@ func TypeNEQ(v string) predicate.Group { ) } +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...string) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldType), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldType, p.Within(v...)) + }, + ) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...string) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldType), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldType, p.Without(v...)) + }, + ) +} + // TypeGT applies the GT predicate on the "type" field. func TypeGT(v string) predicate.Group { return predicate.GroupPerDialect( @@ -432,50 +476,6 @@ func TypeLTE(v string) predicate.Group { ) } -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldType), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldType, p.Within(v...)) - }, - ) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldType), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldType, p.Without(v...)) - }, - ) -} - // TypeContains applies the Contains predicate on the "type" field. func TypeContains(v string) predicate.Group { return predicate.GroupPerDialect( @@ -560,6 +560,50 @@ func MaxUsersNEQ(v int) predicate.Group { ) } +// MaxUsersIn applies the In predicate on the "max_users" field. +func MaxUsersIn(vs ...int) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldMaxUsers), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldMaxUsers, p.Within(v...)) + }, + ) +} + +// MaxUsersNotIn applies the NotIn predicate on the "max_users" field. +func MaxUsersNotIn(vs ...int) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldMaxUsers), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldMaxUsers, p.Without(v...)) + }, + ) +} + // MaxUsersGT applies the GT predicate on the "max_users" field. func MaxUsersGT(v int) predicate.Group { return predicate.GroupPerDialect( @@ -608,50 +652,6 @@ func MaxUsersLTE(v int) predicate.Group { ) } -// MaxUsersIn applies the In predicate on the "max_users" field. -func MaxUsersIn(vs ...int) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldMaxUsers), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldMaxUsers, p.Within(v...)) - }, - ) -} - -// MaxUsersNotIn applies the NotIn predicate on the "max_users" field. -func MaxUsersNotIn(vs ...int) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldMaxUsers), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldMaxUsers, p.Without(v...)) - }, - ) -} - // MaxUsersIsNil applies the IsNil predicate on the "max_users" field. func MaxUsersIsNil() predicate.Group { return predicate.GroupPerDialect( @@ -700,6 +700,50 @@ func NameNEQ(v string) predicate.Group { ) } +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Within(v...)) + }, + ) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Group { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Without(v...)) + }, + ) +} + // NameGT applies the GT predicate on the "name" field. func NameGT(v string) predicate.Group { return predicate.GroupPerDialect( @@ -748,50 +792,6 @@ func NameLTE(v string) predicate.Group { ) } -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Within(v...)) - }, - ) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Group { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Without(v...)) - }, - ) -} - // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.Group { return predicate.GroupPerDialect( diff --git a/entc/integration/ent/groupinfo/where.go b/entc/integration/ent/groupinfo/where.go index 029d0dae0..0345713d9 100644 --- a/entc/integration/ent/groupinfo/where.go +++ b/entc/integration/ent/groupinfo/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.GroupInfo { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.GroupInfo { - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.GroupInfo { - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.GroupInfo { - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.GroupInfo { - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.GroupInfo { return predicate.GroupInfoPerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.GroupInfo { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.GroupInfo { + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.GroupInfo { + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.GroupInfo { + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.GroupInfo { + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Desc applies equality check predicate on the "desc" field. It's identical to DescEQ. func Desc(v string) predicate.GroupInfo { return predicate.GroupInfoPerDialect( @@ -207,6 +207,50 @@ func DescNEQ(v string) predicate.GroupInfo { ) } +// DescIn applies the In predicate on the "desc" field. +func DescIn(vs ...string) predicate.GroupInfo { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldDesc), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldDesc, p.Within(v...)) + }, + ) +} + +// DescNotIn applies the NotIn predicate on the "desc" field. +func DescNotIn(vs ...string) predicate.GroupInfo { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldDesc), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldDesc, p.Without(v...)) + }, + ) +} + // DescGT applies the GT predicate on the "desc" field. func DescGT(v string) predicate.GroupInfo { return predicate.GroupInfoPerDialect( @@ -255,50 +299,6 @@ func DescLTE(v string) predicate.GroupInfo { ) } -// DescIn applies the In predicate on the "desc" field. -func DescIn(vs ...string) predicate.GroupInfo { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldDesc), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldDesc, p.Within(v...)) - }, - ) -} - -// DescNotIn applies the NotIn predicate on the "desc" field. -func DescNotIn(vs ...string) predicate.GroupInfo { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldDesc), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldDesc, p.Without(v...)) - }, - ) -} - // DescContains applies the Contains predicate on the "desc" field. func DescContains(v string) predicate.GroupInfo { return predicate.GroupInfoPerDialect( @@ -359,6 +359,50 @@ func MaxUsersNEQ(v int) predicate.GroupInfo { ) } +// MaxUsersIn applies the In predicate on the "max_users" field. +func MaxUsersIn(vs ...int) predicate.GroupInfo { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldMaxUsers), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldMaxUsers, p.Within(v...)) + }, + ) +} + +// MaxUsersNotIn applies the NotIn predicate on the "max_users" field. +func MaxUsersNotIn(vs ...int) predicate.GroupInfo { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.GroupInfoPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldMaxUsers), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldMaxUsers, p.Without(v...)) + }, + ) +} + // MaxUsersGT applies the GT predicate on the "max_users" field. func MaxUsersGT(v int) predicate.GroupInfo { return predicate.GroupInfoPerDialect( @@ -407,50 +451,6 @@ func MaxUsersLTE(v int) predicate.GroupInfo { ) } -// MaxUsersIn applies the In predicate on the "max_users" field. -func MaxUsersIn(vs ...int) predicate.GroupInfo { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldMaxUsers), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldMaxUsers, p.Within(v...)) - }, - ) -} - -// MaxUsersNotIn applies the NotIn predicate on the "max_users" field. -func MaxUsersNotIn(vs ...int) predicate.GroupInfo { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.GroupInfoPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldMaxUsers), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldMaxUsers, p.Without(v...)) - }, - ) -} - // HasGroups applies the HasEdge predicate on the "groups" edge. func HasGroups() predicate.GroupInfo { return predicate.GroupInfoPerDialect( diff --git a/entc/integration/ent/migrate/schema.go b/entc/integration/ent/migrate/schema.go index 2a76197b9..a3fc5bacf 100644 --- a/entc/integration/ent/migrate/schema.go +++ b/entc/integration/ent/migrate/schema.go @@ -73,6 +73,7 @@ var ( {Name: "nillable_int32", Type: field.TypeInt32, Nullable: true}, {Name: "nillable_int64", Type: field.TypeInt64, Nullable: true}, {Name: "validate_optional_int32", Type: field.TypeInt32, Nullable: true}, + {Name: "state", Type: field.TypeEnum, Nullable: true, Enums: []string{"on", "off"}}, } // FieldTypesTable holds the schema information for the "field_types" table. FieldTypesTable = &schema.Table{ diff --git a/entc/integration/ent/node/where.go b/entc/integration/ent/node/where.go index 4a362f277..a55d47fee 100644 --- a/entc/integration/ent/node/where.go +++ b/entc/integration/ent/node/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.Node { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.Node { - return predicate.NodePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.Node { - return predicate.NodePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.Node { - return predicate.NodePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.Node { - return predicate.NodePerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.Node { return predicate.NodePerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.Node { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Node { + return predicate.NodePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Node { + return predicate.NodePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Node { + return predicate.NodePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Node { + return predicate.NodePerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Value applies equality check predicate on the "value" field. It's identical to ValueEQ. func Value(v int) predicate.Node { return predicate.NodePerDialect( @@ -195,6 +195,50 @@ func ValueNEQ(v int) predicate.Node { ) } +// ValueIn applies the In predicate on the "value" field. +func ValueIn(vs ...int) predicate.Node { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.NodePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldValue), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldValue, p.Within(v...)) + }, + ) +} + +// ValueNotIn applies the NotIn predicate on the "value" field. +func ValueNotIn(vs ...int) predicate.Node { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.NodePerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldValue), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldValue, p.Without(v...)) + }, + ) +} + // ValueGT applies the GT predicate on the "value" field. func ValueGT(v int) predicate.Node { return predicate.NodePerDialect( @@ -243,50 +287,6 @@ func ValueLTE(v int) predicate.Node { ) } -// ValueIn applies the In predicate on the "value" field. -func ValueIn(vs ...int) predicate.Node { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NodePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldValue), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldValue, p.Within(v...)) - }, - ) -} - -// ValueNotIn applies the NotIn predicate on the "value" field. -func ValueNotIn(vs ...int) predicate.Node { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NodePerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldValue), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldValue, p.Without(v...)) - }, - ) -} - // ValueIsNil applies the IsNil predicate on the "value" field. func ValueIsNil() predicate.Node { return predicate.NodePerDialect( diff --git a/entc/integration/ent/pet/where.go b/entc/integration/ent/pet/where.go index e1e88499b..abb65c9b8 100644 --- a/entc/integration/ent/pet/where.go +++ b/entc/integration/ent/pet/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.Pet { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.Pet { - return predicate.PetPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.Pet { - return predicate.PetPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.Pet { - return predicate.PetPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.Pet { - return predicate.PetPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.Pet { return predicate.PetPerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.Pet { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.Pet { + return predicate.PetPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.Pet { + return predicate.PetPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.Pet { + return predicate.PetPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.Pet { + return predicate.PetPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.Pet { return predicate.PetPerDialect( @@ -195,6 +195,50 @@ func NameNEQ(v string) predicate.Pet { ) } +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Pet { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.PetPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Within(v...)) + }, + ) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Pet { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.PetPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Without(v...)) + }, + ) +} + // NameGT applies the GT predicate on the "name" field. func NameGT(v string) predicate.Pet { return predicate.PetPerDialect( @@ -243,50 +287,6 @@ func NameLTE(v string) predicate.Pet { ) } -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Pet { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PetPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Within(v...)) - }, - ) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Pet { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PetPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Without(v...)) - }, - ) -} - // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.Pet { return predicate.PetPerDialect( diff --git a/entc/integration/ent/schema/fieldtype.go b/entc/integration/ent/schema/fieldtype.go index 9fbb4c4b6..b826fd303 100644 --- a/entc/integration/ent/schema/fieldtype.go +++ b/entc/integration/ent/schema/fieldtype.go @@ -36,5 +36,8 @@ func (FieldType) Fields() []ent.Field { field.Int32("validate_optional_int32"). Optional(). Max(100), + field.Enum("state"). + Values("on", "off"). + Optional(), } } diff --git a/entc/integration/ent/user/where.go b/entc/integration/ent/user/where.go index 923c6aef9..32a991d37 100644 --- a/entc/integration/ent/user/where.go +++ b/entc/integration/ent/user/where.go @@ -55,58 +55,6 @@ func IDNEQ(id string) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.User { - return predicate.UserPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GT(id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.User { - return predicate.UserPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.GTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.GTE(id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.User { - return predicate.UserPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LT(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LT(id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.User { - return predicate.UserPerDialect( - func(s *sql.Selector) { - id, _ := strconv.Atoi(id) - s.Where(sql.LTE(s.C(FieldID), id)) - }, - func(t *dsl.Traversal) { - t.HasID(p.LTE(id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...string) predicate.User { return predicate.UserPerDialect( @@ -159,6 +107,58 @@ func IDNotIn(ids ...string) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id string) predicate.User { + return predicate.UserPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GT(id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id string) predicate.User { + return predicate.UserPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.GTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.GTE(id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id string) predicate.User { + return predicate.UserPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LT(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LT(id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id string) predicate.User { + return predicate.UserPerDialect( + func(s *sql.Selector) { + id, _ := strconv.Atoi(id) + s.Where(sql.LTE(s.C(FieldID), id)) + }, + func(t *dsl.Traversal) { + t.HasID(p.LTE(id)) + }, + ) +} + // Age applies equality check predicate on the "age" field. It's identical to AgeEQ. func Age(v int) predicate.User { return predicate.UserPerDialect( @@ -243,6 +243,50 @@ func AgeNEQ(v int) predicate.User { ) } +// AgeIn applies the In predicate on the "age" field. +func AgeIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldAge), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldAge, p.Within(v...)) + }, + ) +} + +// AgeNotIn applies the NotIn predicate on the "age" field. +func AgeNotIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldAge), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldAge, p.Without(v...)) + }, + ) +} + // AgeGT applies the GT predicate on the "age" field. func AgeGT(v int) predicate.User { return predicate.UserPerDialect( @@ -291,50 +335,6 @@ func AgeLTE(v int) predicate.User { ) } -// AgeIn applies the In predicate on the "age" field. -func AgeIn(vs ...int) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldAge), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldAge, p.Within(v...)) - }, - ) -} - -// AgeNotIn applies the NotIn predicate on the "age" field. -func AgeNotIn(vs ...int) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldAge), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldAge, p.Without(v...)) - }, - ) -} - // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.User { return predicate.UserPerDialect( @@ -359,6 +359,50 @@ func NameNEQ(v string) predicate.User { ) } +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Within(v...)) + }, + ) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldName), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldName, p.Without(v...)) + }, + ) +} + // NameGT applies the GT predicate on the "name" field. func NameGT(v string) predicate.User { return predicate.UserPerDialect( @@ -407,50 +451,6 @@ func NameLTE(v string) predicate.User { ) } -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Within(v...)) - }, - ) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldName, p.Without(v...)) - }, - ) -} - // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.User { return predicate.UserPerDialect( @@ -511,6 +511,50 @@ func LastNEQ(v string) predicate.User { ) } +// LastIn applies the In predicate on the "last" field. +func LastIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldLast), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldLast, p.Within(v...)) + }, + ) +} + +// LastNotIn applies the NotIn predicate on the "last" field. +func LastNotIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldLast), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldLast, p.Without(v...)) + }, + ) +} + // LastGT applies the GT predicate on the "last" field. func LastGT(v string) predicate.User { return predicate.UserPerDialect( @@ -559,50 +603,6 @@ func LastLTE(v string) predicate.User { ) } -// LastIn applies the In predicate on the "last" field. -func LastIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldLast), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldLast, p.Within(v...)) - }, - ) -} - -// LastNotIn applies the NotIn predicate on the "last" field. -func LastNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldLast), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldLast, p.Without(v...)) - }, - ) -} - // LastContains applies the Contains predicate on the "last" field. func LastContains(v string) predicate.User { return predicate.UserPerDialect( @@ -663,6 +663,50 @@ func NicknameNEQ(v string) predicate.User { ) } +// NicknameIn applies the In predicate on the "nickname" field. +func NicknameIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldNickname), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNickname, p.Within(v...)) + }, + ) +} + +// NicknameNotIn applies the NotIn predicate on the "nickname" field. +func NicknameNotIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldNickname), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldNickname, p.Without(v...)) + }, + ) +} + // NicknameGT applies the GT predicate on the "nickname" field. func NicknameGT(v string) predicate.User { return predicate.UserPerDialect( @@ -711,50 +755,6 @@ func NicknameLTE(v string) predicate.User { ) } -// NicknameIn applies the In predicate on the "nickname" field. -func NicknameIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldNickname), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNickname, p.Within(v...)) - }, - ) -} - -// NicknameNotIn applies the NotIn predicate on the "nickname" field. -func NicknameNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldNickname), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldNickname, p.Without(v...)) - }, - ) -} - // NicknameContains applies the Contains predicate on the "nickname" field. func NicknameContains(v string) predicate.User { return predicate.UserPerDialect( @@ -839,6 +839,50 @@ func PhoneNEQ(v string) predicate.User { ) } +// PhoneIn applies the In predicate on the "phone" field. +func PhoneIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldPhone), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldPhone, p.Within(v...)) + }, + ) +} + +// PhoneNotIn applies the NotIn predicate on the "phone" field. +func PhoneNotIn(vs ...string) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.UserPerDialect( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldPhone), v...)) + }, + func(t *dsl.Traversal) { + t.Has(Label, FieldPhone, p.Without(v...)) + }, + ) +} + // PhoneGT applies the GT predicate on the "phone" field. func PhoneGT(v string) predicate.User { return predicate.UserPerDialect( @@ -887,50 +931,6 @@ func PhoneLTE(v string) predicate.User { ) } -// PhoneIn applies the In predicate on the "phone" field. -func PhoneIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldPhone), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldPhone, p.Within(v...)) - }, - ) -} - -// PhoneNotIn applies the NotIn predicate on the "phone" field. -func PhoneNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.UserPerDialect( - func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(vs) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldPhone), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldPhone, p.Without(v...)) - }, - ) -} - // PhoneContains applies the Contains predicate on the "phone" field. func PhoneContains(v string) predicate.User { return predicate.UserPerDialect( diff --git a/entc/integration/idtype/ent/user/where.go b/entc/integration/idtype/ent/user/where.go index 7c609bf9c..c3dfc03c8 100644 --- a/entc/integration/idtype/ent/user/where.go +++ b/entc/integration/idtype/ent/user/where.go @@ -38,42 +38,6 @@ func IDNEQ(id uint64) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id uint64) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id uint64) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id uint64) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id uint64) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...uint64) predicate.User { return predicate.User( @@ -112,6 +76,42 @@ func IDNotIn(ids ...uint64) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.User { return predicate.User( @@ -139,42 +139,6 @@ func NameNEQ(v string) predicate.User { ) } -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }, - ) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }, - ) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }, - ) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }, - ) -} - // NameIn applies the In predicate on the "name" field. func NameIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -213,6 +177,42 @@ func NameNotIn(vs ...string) predicate.User { ) } +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldName), v)) + }, + ) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldName), v)) + }, + ) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldName), v)) + }, + ) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldName), v)) + }, + ) +} + // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.User { return predicate.User( diff --git a/entc/integration/json/ent/user/where.go b/entc/integration/json/ent/user/where.go index 435ba7972..5029cc365 100644 --- a/entc/integration/json/ent/user/where.go +++ b/entc/integration/json/ent/user/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.User { return predicate.User( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // URLIsNil applies the IsNil predicate on the "url" field. func URLIsNil() predicate.User { return predicate.User( diff --git a/entc/integration/migrate/entv1/example_test.go b/entc/integration/migrate/entv1/example_test.go index c4b10911e..c02f9d64f 100644 --- a/entc/integration/migrate/entv1/example_test.go +++ b/entc/integration/migrate/entv1/example_test.go @@ -11,6 +11,8 @@ import ( "log" "github.com/facebookincubator/ent/dialect/sql" + + "github.com/facebookincubator/ent/entc/integration/migrate/entv1/user" ) // dsn for the database. In order to run the tests locally, run the following command: @@ -40,6 +42,7 @@ func ExampleUser() { SetAddress("string"). SetRenamed("string"). SetBlob(nil). + SetState(user.StateLoggedIn). SaveX(ctx) log.Println("user created:", u) diff --git a/entc/integration/migrate/entv1/migrate/schema.go b/entc/integration/migrate/entv1/migrate/schema.go index 7768a1026..de8e36bdf 100644 --- a/entc/integration/migrate/entv1/migrate/schema.go +++ b/entc/integration/migrate/entv1/migrate/schema.go @@ -20,6 +20,7 @@ var ( {Name: "address", Type: field.TypeString, Nullable: true}, {Name: "renamed", Type: field.TypeString, Nullable: true}, {Name: "blob", Type: field.TypeBytes, Nullable: true, Size: 255}, + {Name: "state", Type: field.TypeEnum, Nullable: true, Enums: []string{"logged_in", "logged_out"}}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ diff --git a/entc/integration/migrate/entv1/schema/user.go b/entc/integration/migrate/entv1/schema/user.go index 4419327c2..8ece0784f 100644 --- a/entc/integration/migrate/entv1/schema/user.go +++ b/entc/integration/migrate/entv1/schema/user.go @@ -26,6 +26,9 @@ func (User) Fields() []ent.Field { field.Bytes("blob"). Optional(). MaxLen(255), + field.Enum("state"). + Optional(). + Values("logged_in", "logged_out"), } } diff --git a/entc/integration/migrate/entv1/user.go b/entc/integration/migrate/entv1/user.go index 4cff708aa..db4691905 100644 --- a/entc/integration/migrate/entv1/user.go +++ b/entc/integration/migrate/entv1/user.go @@ -11,6 +11,7 @@ import ( "fmt" "github.com/facebookincubator/ent/dialect/sql" + "github.com/facebookincubator/ent/entc/integration/migrate/entv1/user" ) // User is the model entity for the User schema. @@ -28,6 +29,8 @@ type User struct { Renamed string `json:"renamed,omitempty"` // Blob holds the value of the "blob" field. Blob []byte `json:"blob,omitempty"` + // State holds the value of the "state" field. + State user.State `json:"state,omitempty"` } // FromRows scans the sql response data into User. @@ -39,6 +42,7 @@ func (u *User) FromRows(rows *sql.Rows) error { Address sql.NullString Renamed sql.NullString Blob []byte + State sql.NullString } // the order here should be the same as in the `user.Columns`. if err := rows.Scan( @@ -48,6 +52,7 @@ func (u *User) FromRows(rows *sql.Rows) error { &vu.Address, &vu.Renamed, &vu.Blob, + &vu.State, ); err != nil { return err } @@ -57,6 +62,7 @@ func (u *User) FromRows(rows *sql.Rows) error { u.Address = vu.Address.String u.Renamed = vu.Renamed.String u.Blob = vu.Blob + u.State = user.State(vu.State.String) return nil } @@ -88,6 +94,7 @@ func (u *User) String() string { buf.WriteString(fmt.Sprintf(", address=%v", u.Address)) buf.WriteString(fmt.Sprintf(", renamed=%v", u.Renamed)) buf.WriteString(fmt.Sprintf(", blob=%v", u.Blob)) + buf.WriteString(fmt.Sprintf(", state=%v", u.State)) buf.WriteString(")") return buf.String() } diff --git a/entc/integration/migrate/entv1/user/user.go b/entc/integration/migrate/entv1/user/user.go index 7e4005a4a..f61b136ca 100644 --- a/entc/integration/migrate/entv1/user/user.go +++ b/entc/integration/migrate/entv1/user/user.go @@ -7,6 +7,8 @@ package user import ( + "fmt" + "github.com/facebookincubator/ent/entc/integration/migrate/entv1/schema" ) @@ -25,6 +27,8 @@ const ( FieldRenamed = "renamed" // FieldBlob holds the string denoting the blob vertex property in the database. FieldBlob = "blob" + // FieldState holds the string denoting the state vertex property in the database. + FieldState = "state" // Table holds the table name of the user in the database. Table = "users" @@ -38,6 +42,7 @@ var Columns = []string{ FieldAddress, FieldRenamed, FieldBlob, + FieldState, } var ( @@ -48,3 +53,25 @@ var ( // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator = descName.Validators[0].(func(string) error) ) + +// State defines the type for the state enum field. +type State string + +const ( + StateLoggedIn State = "logged_in" + StateLoggedOut State = "logged_out" +) + +func (s State) String() string { + return string(s) +} + +// StateValidator is a validator for the "state" field enum values. It is called by the builders before save. +func StateValidator(state State) error { + switch state { + case StateLoggedIn, StateLoggedOut: + return nil + default: + return fmt.Errorf("user: invalid enum value for state field: %q", state) + } +} diff --git a/entc/integration/migrate/entv1/user/where.go b/entc/integration/migrate/entv1/user/where.go index cf8d886a1..ddd776af0 100644 --- a/entc/integration/migrate/entv1/user/where.go +++ b/entc/integration/migrate/entv1/user/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.User { return predicate.User( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // Age applies equality check predicate on the "age" field. It's identical to AgeEQ. func Age(v int32) predicate.User { return predicate.User( @@ -175,42 +175,6 @@ func AgeNEQ(v int32) predicate.User { ) } -// AgeGT applies the GT predicate on the "age" field. -func AgeGT(v int32) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAge), v)) - }, - ) -} - -// AgeGTE applies the GTE predicate on the "age" field. -func AgeGTE(v int32) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAge), v)) - }, - ) -} - -// AgeLT applies the LT predicate on the "age" field. -func AgeLT(v int32) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAge), v)) - }, - ) -} - -// AgeLTE applies the LTE predicate on the "age" field. -func AgeLTE(v int32) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAge), v)) - }, - ) -} - // AgeIn applies the In predicate on the "age" field. func AgeIn(vs ...int32) predicate.User { v := make([]interface{}, len(vs)) @@ -249,6 +213,42 @@ func AgeNotIn(vs ...int32) predicate.User { ) } +// AgeGT applies the GT predicate on the "age" field. +func AgeGT(v int32) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldAge), v)) + }, + ) +} + +// AgeGTE applies the GTE predicate on the "age" field. +func AgeGTE(v int32) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldAge), v)) + }, + ) +} + +// AgeLT applies the LT predicate on the "age" field. +func AgeLT(v int32) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldAge), v)) + }, + ) +} + +// AgeLTE applies the LTE predicate on the "age" field. +func AgeLTE(v int32) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldAge), v)) + }, + ) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.User { return predicate.User( @@ -267,42 +267,6 @@ func NameNEQ(v string) predicate.User { ) } -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }, - ) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }, - ) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }, - ) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }, - ) -} - // NameIn applies the In predicate on the "name" field. func NameIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -341,6 +305,42 @@ func NameNotIn(vs ...string) predicate.User { ) } +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldName), v)) + }, + ) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldName), v)) + }, + ) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldName), v)) + }, + ) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldName), v)) + }, + ) +} + // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.User { return predicate.User( @@ -404,42 +404,6 @@ func AddressNEQ(v string) predicate.User { ) } -// AddressGT applies the GT predicate on the "address" field. -func AddressGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAddress), v)) - }, - ) -} - -// AddressGTE applies the GTE predicate on the "address" field. -func AddressGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAddress), v)) - }, - ) -} - -// AddressLT applies the LT predicate on the "address" field. -func AddressLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAddress), v)) - }, - ) -} - -// AddressLTE applies the LTE predicate on the "address" field. -func AddressLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAddress), v)) - }, - ) -} - // AddressIn applies the In predicate on the "address" field. func AddressIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -478,6 +442,42 @@ func AddressNotIn(vs ...string) predicate.User { ) } +// AddressGT applies the GT predicate on the "address" field. +func AddressGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldAddress), v)) + }, + ) +} + +// AddressGTE applies the GTE predicate on the "address" field. +func AddressGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldAddress), v)) + }, + ) +} + +// AddressLT applies the LT predicate on the "address" field. +func AddressLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldAddress), v)) + }, + ) +} + +// AddressLTE applies the LTE predicate on the "address" field. +func AddressLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldAddress), v)) + }, + ) +} + // AddressContains applies the Contains predicate on the "address" field. func AddressContains(v string) predicate.User { return predicate.User( @@ -559,42 +559,6 @@ func RenamedNEQ(v string) predicate.User { ) } -// RenamedGT applies the GT predicate on the "renamed" field. -func RenamedGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRenamed), v)) - }, - ) -} - -// RenamedGTE applies the GTE predicate on the "renamed" field. -func RenamedGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRenamed), v)) - }, - ) -} - -// RenamedLT applies the LT predicate on the "renamed" field. -func RenamedLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRenamed), v)) - }, - ) -} - -// RenamedLTE applies the LTE predicate on the "renamed" field. -func RenamedLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRenamed), v)) - }, - ) -} - // RenamedIn applies the In predicate on the "renamed" field. func RenamedIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -633,6 +597,42 @@ func RenamedNotIn(vs ...string) predicate.User { ) } +// RenamedGT applies the GT predicate on the "renamed" field. +func RenamedGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldRenamed), v)) + }, + ) +} + +// RenamedGTE applies the GTE predicate on the "renamed" field. +func RenamedGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldRenamed), v)) + }, + ) +} + +// RenamedLT applies the LT predicate on the "renamed" field. +func RenamedLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldRenamed), v)) + }, + ) +} + +// RenamedLTE applies the LTE predicate on the "renamed" field. +func RenamedLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldRenamed), v)) + }, + ) +} + // RenamedContains applies the Contains predicate on the "renamed" field. func RenamedContains(v string) predicate.User { return predicate.User( @@ -714,42 +714,6 @@ func BlobNEQ(v []byte) predicate.User { ) } -// BlobGT applies the GT predicate on the "blob" field. -func BlobGT(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldBlob), v)) - }, - ) -} - -// BlobGTE applies the GTE predicate on the "blob" field. -func BlobGTE(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldBlob), v)) - }, - ) -} - -// BlobLT applies the LT predicate on the "blob" field. -func BlobLT(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldBlob), v)) - }, - ) -} - -// BlobLTE applies the LTE predicate on the "blob" field. -func BlobLTE(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldBlob), v)) - }, - ) -} - // BlobIn applies the In predicate on the "blob" field. func BlobIn(vs ...[]byte) predicate.User { v := make([]interface{}, len(vs)) @@ -788,6 +752,42 @@ func BlobNotIn(vs ...[]byte) predicate.User { ) } +// BlobGT applies the GT predicate on the "blob" field. +func BlobGT(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldBlob), v)) + }, + ) +} + +// BlobGTE applies the GTE predicate on the "blob" field. +func BlobGTE(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldBlob), v)) + }, + ) +} + +// BlobLT applies the LT predicate on the "blob" field. +func BlobLT(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldBlob), v)) + }, + ) +} + +// BlobLTE applies the LTE predicate on the "blob" field. +func BlobLTE(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldBlob), v)) + }, + ) +} + // BlobIsNil applies the IsNil predicate on the "blob" field. func BlobIsNil() predicate.User { return predicate.User( @@ -806,6 +806,80 @@ func BlobNotNil() predicate.User { ) } +// StateEQ applies the EQ predicate on the "state" field. +func StateEQ(v State) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldState), v)) + }, + ) +} + +// StateNEQ applies the NEQ predicate on the "state" field. +func StateNEQ(v State) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldState), v)) + }, + ) +} + +// StateIn applies the In predicate on the "state" field. +func StateIn(vs ...State) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldState), v...)) + }, + ) +} + +// StateNotIn applies the NotIn predicate on the "state" field. +func StateNotIn(vs ...State) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldState), v...)) + }, + ) +} + +// StateIsNil applies the IsNil predicate on the "state" field. +func StateIsNil() predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldState))) + }, + ) +} + +// StateNotNil applies the NotNil predicate on the "state" field. +func StateNotNil() predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldState))) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { return predicate.User( diff --git a/entc/integration/migrate/entv1/user_create.go b/entc/integration/migrate/entv1/user_create.go index 10f005f0d..23af336f7 100644 --- a/entc/integration/migrate/entv1/user_create.go +++ b/entc/integration/migrate/entv1/user_create.go @@ -23,6 +23,7 @@ type UserCreate struct { address *string renamed *string blob *[]byte + state *user.State } // SetAge sets the age field. @@ -71,6 +72,20 @@ func (uc *UserCreate) SetBlob(b []byte) *UserCreate { return uc } +// SetState sets the state field. +func (uc *UserCreate) SetState(u user.State) *UserCreate { + uc.state = &u + return uc +} + +// SetNillableState sets the state field if the given value is not nil. +func (uc *UserCreate) SetNillableState(u *user.State) *UserCreate { + if u != nil { + uc.SetState(*u) + } + return uc +} + // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { if uc.age == nil { @@ -82,6 +97,11 @@ func (uc *UserCreate) Save(ctx context.Context) (*User, error) { if err := user.NameValidator(*uc.name); err != nil { return nil, fmt.Errorf("entv1: validator failed for field \"name\": %v", err) } + if uc.state != nil { + if err := user.StateValidator(*uc.state); err != nil { + return nil, fmt.Errorf("entv1: validator failed for field \"state\": %v", err) + } + } return uc.sqlSave(ctx) } @@ -124,6 +144,10 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { builder.Set(user.FieldBlob, *value) u.Blob = *value } + if value := uc.state; value != nil { + builder.Set(user.FieldState, *value) + u.State = *value + } query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { return nil, rollback(tx, err) diff --git a/entc/integration/migrate/entv1/user_update.go b/entc/integration/migrate/entv1/user_update.go index 5cd1e78bb..a54b23543 100644 --- a/entc/integration/migrate/entv1/user_update.go +++ b/entc/integration/migrate/entv1/user_update.go @@ -27,6 +27,8 @@ type UserUpdate struct { clearrenamed bool blob *[]byte clearblob bool + state *user.State + clearstate bool predicates []predicate.User } @@ -114,6 +116,27 @@ func (uu *UserUpdate) ClearBlob() *UserUpdate { return uu } +// SetState sets the state field. +func (uu *UserUpdate) SetState(u user.State) *UserUpdate { + uu.state = &u + return uu +} + +// SetNillableState sets the state field if the given value is not nil. +func (uu *UserUpdate) SetNillableState(u *user.State) *UserUpdate { + if u != nil { + uu.SetState(*u) + } + return uu +} + +// ClearState clears the value of state. +func (uu *UserUpdate) ClearState() *UserUpdate { + uu.state = nil + uu.clearstate = true + return uu +} + // Save executes the query and returns the number of rows/vertices matched by this operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { if uu.name != nil { @@ -121,6 +144,11 @@ func (uu *UserUpdate) Save(ctx context.Context) (int, error) { return 0, fmt.Errorf("entv1: validator failed for field \"name\": %v", err) } } + if uu.state != nil { + if err := user.StateValidator(*uu.state); err != nil { + return 0, fmt.Errorf("entv1: validator failed for field \"state\": %v", err) + } + } return uu.sqlSave(ctx) } @@ -204,6 +232,12 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if uu.clearblob { builder.SetNull(user.FieldBlob) } + if value := uu.state; value != nil { + builder.Set(user.FieldState, *value) + } + if uu.clearstate { + builder.SetNull(user.FieldState) + } if !builder.Empty() { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { @@ -229,6 +263,8 @@ type UserUpdateOne struct { clearrenamed bool blob *[]byte clearblob bool + state *user.State + clearstate bool } // SetAge sets the age field. @@ -309,6 +345,27 @@ func (uuo *UserUpdateOne) ClearBlob() *UserUpdateOne { return uuo } +// SetState sets the state field. +func (uuo *UserUpdateOne) SetState(u user.State) *UserUpdateOne { + uuo.state = &u + return uuo +} + +// SetNillableState sets the state field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableState(u *user.State) *UserUpdateOne { + if u != nil { + uuo.SetState(*u) + } + return uuo +} + +// ClearState clears the value of state. +func (uuo *UserUpdateOne) ClearState() *UserUpdateOne { + uuo.state = nil + uuo.clearstate = true + return uuo +} + // Save executes the query and returns the updated entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { if uuo.name != nil { @@ -316,6 +373,11 @@ func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { return nil, fmt.Errorf("entv1: validator failed for field \"name\": %v", err) } } + if uuo.state != nil { + if err := user.StateValidator(*uuo.state); err != nil { + return nil, fmt.Errorf("entv1: validator failed for field \"state\": %v", err) + } + } return uuo.sqlSave(ctx) } @@ -414,6 +476,15 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (u *User, err error) { u.Blob = value builder.SetNull(user.FieldBlob) } + if value := uuo.state; value != nil { + builder.Set(user.FieldState, *value) + u.State = *value + } + if uuo.clearstate { + var value user.State + u.State = value + builder.SetNull(user.FieldState) + } if !builder.Empty() { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { diff --git a/entc/integration/migrate/entv2/example_test.go b/entc/integration/migrate/entv2/example_test.go index 2e25ac104..fd1f4d13f 100644 --- a/entc/integration/migrate/entv2/example_test.go +++ b/entc/integration/migrate/entv2/example_test.go @@ -11,6 +11,8 @@ import ( "log" "github.com/facebookincubator/ent/dialect/sql" + + "github.com/facebookincubator/ent/entc/integration/migrate/entv2/user" ) // dsn for the database. In order to run the tests locally, run the following command: @@ -88,6 +90,7 @@ func ExampleUser() { SetTitle("string"). SetNewName("string"). SetBlob(nil). + SetState(user.StateLoggedIn). SaveX(ctx) log.Println("user created:", u) diff --git a/entc/integration/migrate/entv2/group/where.go b/entc/integration/migrate/entv2/group/where.go index e6412abb0..8bbd9ebf5 100644 --- a/entc/integration/migrate/entv2/group/where.go +++ b/entc/integration/migrate/entv2/group/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.Group { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Group { return predicate.Group( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.Group { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { return predicate.Group( diff --git a/entc/integration/migrate/entv2/migrate/schema.go b/entc/integration/migrate/entv2/migrate/schema.go index ffcf02214..b37332c66 100644 --- a/entc/integration/migrate/entv2/migrate/schema.go +++ b/entc/integration/migrate/entv2/migrate/schema.go @@ -46,6 +46,7 @@ var ( {Name: "title", Type: field.TypeString, Default: user.DefaultTitle}, {Name: "renamed", Type: field.TypeString, Nullable: true}, {Name: "blob", Type: field.TypeBytes, Nullable: true, Size: 1000}, + {Name: "state", Type: field.TypeEnum, Nullable: true, Enums: []string{"logged_in", "logged_out", "online"}}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ diff --git a/entc/integration/migrate/entv2/pet/where.go b/entc/integration/migrate/entv2/pet/where.go index 93fcf1b3b..2a60fdda6 100644 --- a/entc/integration/migrate/entv2/pet/where.go +++ b/entc/integration/migrate/entv2/pet/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.Pet { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Pet { return predicate.Pet( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.Pet { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.Pet) predicate.Pet { return predicate.Pet( diff --git a/entc/integration/migrate/entv2/schema/user.go b/entc/integration/migrate/entv2/schema/user.go index 8fa690fe0..410714840 100644 --- a/entc/integration/migrate/entv2/schema/user.go +++ b/entc/integration/migrate/entv2/schema/user.go @@ -40,6 +40,10 @@ func (User) Fields() []ent.Field { field.Bytes("blob"). Optional(). MaxLen(1000), + // adding enum to the `state` column. + field.Enum("state"). + Optional(). + Values("logged_in", "logged_out", "online"), // deleting the `address` column. } } diff --git a/entc/integration/migrate/entv2/user.go b/entc/integration/migrate/entv2/user.go index a58582135..1dd1323a2 100644 --- a/entc/integration/migrate/entv2/user.go +++ b/entc/integration/migrate/entv2/user.go @@ -11,6 +11,7 @@ import ( "fmt" "github.com/facebookincubator/ent/dialect/sql" + "github.com/facebookincubator/ent/entc/integration/migrate/entv2/user" ) // User is the model entity for the User schema. @@ -32,6 +33,8 @@ type User struct { NewName string `json:"new_name,omitempty"` // Blob holds the value of the "blob" field. Blob []byte `json:"blob,omitempty"` + // State holds the value of the "state" field. + State user.State `json:"state,omitempty"` } // FromRows scans the sql response data into User. @@ -45,6 +48,7 @@ func (u *User) FromRows(rows *sql.Rows) error { Title sql.NullString NewName sql.NullString Blob []byte + State sql.NullString } // the order here should be the same as in the `user.Columns`. if err := rows.Scan( @@ -56,6 +60,7 @@ func (u *User) FromRows(rows *sql.Rows) error { &vu.Title, &vu.NewName, &vu.Blob, + &vu.State, ); err != nil { return err } @@ -67,6 +72,7 @@ func (u *User) FromRows(rows *sql.Rows) error { u.Title = vu.Title.String u.NewName = vu.NewName.String u.Blob = vu.Blob + u.State = user.State(vu.State.String) return nil } @@ -100,6 +106,7 @@ func (u *User) String() string { buf.WriteString(fmt.Sprintf(", title=%v", u.Title)) buf.WriteString(fmt.Sprintf(", new_name=%v", u.NewName)) buf.WriteString(fmt.Sprintf(", blob=%v", u.Blob)) + buf.WriteString(fmt.Sprintf(", state=%v", u.State)) buf.WriteString(")") return buf.String() } diff --git a/entc/integration/migrate/entv2/user/user.go b/entc/integration/migrate/entv2/user/user.go index 18061dd1d..4102190b7 100644 --- a/entc/integration/migrate/entv2/user/user.go +++ b/entc/integration/migrate/entv2/user/user.go @@ -7,6 +7,8 @@ package user import ( + "fmt" + "github.com/facebookincubator/ent/entc/integration/migrate/entv2/schema" ) @@ -29,6 +31,8 @@ const ( FieldNewName = "renamed" // FieldBlob holds the string denoting the blob vertex property in the database. FieldBlob = "blob" + // FieldState holds the string denoting the state vertex property in the database. + FieldState = "state" // Table holds the table name of the user in the database. Table = "users" @@ -44,6 +48,7 @@ var Columns = []string{ FieldTitle, FieldNewName, FieldBlob, + FieldState, } var ( @@ -59,3 +64,26 @@ var ( // DefaultTitle holds the default value on creation for the title field. DefaultTitle = descTitle.Default.(string) ) + +// State defines the type for the state enum field. +type State string + +const ( + StateLoggedIn State = "logged_in" + StateLoggedOut State = "logged_out" + StateOnline State = "online" +) + +func (s State) String() string { + return string(s) +} + +// StateValidator is a validator for the "state" field enum values. It is called by the builders before save. +func StateValidator(state State) error { + switch state { + case StateLoggedIn, StateLoggedOut, StateOnline: + return nil + default: + return fmt.Errorf("user: invalid enum value for state field: %q", state) + } +} diff --git a/entc/integration/migrate/entv2/user/where.go b/entc/integration/migrate/entv2/user/where.go index cb81fe688..ccf7fd839 100644 --- a/entc/integration/migrate/entv2/user/where.go +++ b/entc/integration/migrate/entv2/user/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.User { return predicate.User( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // Age applies equality check predicate on the "age" field. It's identical to AgeEQ. func Age(v int) predicate.User { return predicate.User( @@ -193,42 +193,6 @@ func AgeNEQ(v int) predicate.User { ) } -// AgeGT applies the GT predicate on the "age" field. -func AgeGT(v int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAge), v)) - }, - ) -} - -// AgeGTE applies the GTE predicate on the "age" field. -func AgeGTE(v int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAge), v)) - }, - ) -} - -// AgeLT applies the LT predicate on the "age" field. -func AgeLT(v int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAge), v)) - }, - ) -} - -// AgeLTE applies the LTE predicate on the "age" field. -func AgeLTE(v int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAge), v)) - }, - ) -} - // AgeIn applies the In predicate on the "age" field. func AgeIn(vs ...int) predicate.User { v := make([]interface{}, len(vs)) @@ -267,6 +231,42 @@ func AgeNotIn(vs ...int) predicate.User { ) } +// AgeGT applies the GT predicate on the "age" field. +func AgeGT(v int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldAge), v)) + }, + ) +} + +// AgeGTE applies the GTE predicate on the "age" field. +func AgeGTE(v int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldAge), v)) + }, + ) +} + +// AgeLT applies the LT predicate on the "age" field. +func AgeLT(v int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldAge), v)) + }, + ) +} + +// AgeLTE applies the LTE predicate on the "age" field. +func AgeLTE(v int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldAge), v)) + }, + ) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.User { return predicate.User( @@ -285,42 +285,6 @@ func NameNEQ(v string) predicate.User { ) } -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }, - ) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }, - ) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }, - ) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }, - ) -} - // NameIn applies the In predicate on the "name" field. func NameIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -359,6 +323,42 @@ func NameNotIn(vs ...string) predicate.User { ) } +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldName), v)) + }, + ) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldName), v)) + }, + ) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldName), v)) + }, + ) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldName), v)) + }, + ) +} + // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.User { return predicate.User( @@ -422,42 +422,6 @@ func PhoneNEQ(v string) predicate.User { ) } -// PhoneGT applies the GT predicate on the "phone" field. -func PhoneGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldPhone), v)) - }, - ) -} - -// PhoneGTE applies the GTE predicate on the "phone" field. -func PhoneGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldPhone), v)) - }, - ) -} - -// PhoneLT applies the LT predicate on the "phone" field. -func PhoneLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldPhone), v)) - }, - ) -} - -// PhoneLTE applies the LTE predicate on the "phone" field. -func PhoneLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldPhone), v)) - }, - ) -} - // PhoneIn applies the In predicate on the "phone" field. func PhoneIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -496,6 +460,42 @@ func PhoneNotIn(vs ...string) predicate.User { ) } +// PhoneGT applies the GT predicate on the "phone" field. +func PhoneGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldPhone), v)) + }, + ) +} + +// PhoneGTE applies the GTE predicate on the "phone" field. +func PhoneGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldPhone), v)) + }, + ) +} + +// PhoneLT applies the LT predicate on the "phone" field. +func PhoneLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldPhone), v)) + }, + ) +} + +// PhoneLTE applies the LTE predicate on the "phone" field. +func PhoneLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldPhone), v)) + }, + ) +} + // PhoneContains applies the Contains predicate on the "phone" field. func PhoneContains(v string) predicate.User { return predicate.User( @@ -559,42 +559,6 @@ func BufferNEQ(v []byte) predicate.User { ) } -// BufferGT applies the GT predicate on the "buffer" field. -func BufferGT(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldBuffer), v)) - }, - ) -} - -// BufferGTE applies the GTE predicate on the "buffer" field. -func BufferGTE(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldBuffer), v)) - }, - ) -} - -// BufferLT applies the LT predicate on the "buffer" field. -func BufferLT(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldBuffer), v)) - }, - ) -} - -// BufferLTE applies the LTE predicate on the "buffer" field. -func BufferLTE(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldBuffer), v)) - }, - ) -} - // BufferIn applies the In predicate on the "buffer" field. func BufferIn(vs ...[]byte) predicate.User { v := make([]interface{}, len(vs)) @@ -633,6 +597,42 @@ func BufferNotIn(vs ...[]byte) predicate.User { ) } +// BufferGT applies the GT predicate on the "buffer" field. +func BufferGT(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldBuffer), v)) + }, + ) +} + +// BufferGTE applies the GTE predicate on the "buffer" field. +func BufferGTE(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldBuffer), v)) + }, + ) +} + +// BufferLT applies the LT predicate on the "buffer" field. +func BufferLT(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldBuffer), v)) + }, + ) +} + +// BufferLTE applies the LTE predicate on the "buffer" field. +func BufferLTE(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldBuffer), v)) + }, + ) +} + // TitleEQ applies the EQ predicate on the "title" field. func TitleEQ(v string) predicate.User { return predicate.User( @@ -651,42 +651,6 @@ func TitleNEQ(v string) predicate.User { ) } -// TitleGT applies the GT predicate on the "title" field. -func TitleGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldTitle), v)) - }, - ) -} - -// TitleGTE applies the GTE predicate on the "title" field. -func TitleGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldTitle), v)) - }, - ) -} - -// TitleLT applies the LT predicate on the "title" field. -func TitleLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldTitle), v)) - }, - ) -} - -// TitleLTE applies the LTE predicate on the "title" field. -func TitleLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldTitle), v)) - }, - ) -} - // TitleIn applies the In predicate on the "title" field. func TitleIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -725,6 +689,42 @@ func TitleNotIn(vs ...string) predicate.User { ) } +// TitleGT applies the GT predicate on the "title" field. +func TitleGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldTitle), v)) + }, + ) +} + +// TitleGTE applies the GTE predicate on the "title" field. +func TitleGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldTitle), v)) + }, + ) +} + +// TitleLT applies the LT predicate on the "title" field. +func TitleLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldTitle), v)) + }, + ) +} + +// TitleLTE applies the LTE predicate on the "title" field. +func TitleLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldTitle), v)) + }, + ) +} + // TitleContains applies the Contains predicate on the "title" field. func TitleContains(v string) predicate.User { return predicate.User( @@ -788,42 +788,6 @@ func NewNameNEQ(v string) predicate.User { ) } -// NewNameGT applies the GT predicate on the "new_name" field. -func NewNameGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldNewName), v)) - }, - ) -} - -// NewNameGTE applies the GTE predicate on the "new_name" field. -func NewNameGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldNewName), v)) - }, - ) -} - -// NewNameLT applies the LT predicate on the "new_name" field. -func NewNameLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldNewName), v)) - }, - ) -} - -// NewNameLTE applies the LTE predicate on the "new_name" field. -func NewNameLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldNewName), v)) - }, - ) -} - // NewNameIn applies the In predicate on the "new_name" field. func NewNameIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -862,6 +826,42 @@ func NewNameNotIn(vs ...string) predicate.User { ) } +// NewNameGT applies the GT predicate on the "new_name" field. +func NewNameGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldNewName), v)) + }, + ) +} + +// NewNameGTE applies the GTE predicate on the "new_name" field. +func NewNameGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldNewName), v)) + }, + ) +} + +// NewNameLT applies the LT predicate on the "new_name" field. +func NewNameLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldNewName), v)) + }, + ) +} + +// NewNameLTE applies the LTE predicate on the "new_name" field. +func NewNameLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldNewName), v)) + }, + ) +} + // NewNameContains applies the Contains predicate on the "new_name" field. func NewNameContains(v string) predicate.User { return predicate.User( @@ -943,42 +943,6 @@ func BlobNEQ(v []byte) predicate.User { ) } -// BlobGT applies the GT predicate on the "blob" field. -func BlobGT(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldBlob), v)) - }, - ) -} - -// BlobGTE applies the GTE predicate on the "blob" field. -func BlobGTE(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldBlob), v)) - }, - ) -} - -// BlobLT applies the LT predicate on the "blob" field. -func BlobLT(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldBlob), v)) - }, - ) -} - -// BlobLTE applies the LTE predicate on the "blob" field. -func BlobLTE(v []byte) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldBlob), v)) - }, - ) -} - // BlobIn applies the In predicate on the "blob" field. func BlobIn(vs ...[]byte) predicate.User { v := make([]interface{}, len(vs)) @@ -1017,6 +981,42 @@ func BlobNotIn(vs ...[]byte) predicate.User { ) } +// BlobGT applies the GT predicate on the "blob" field. +func BlobGT(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldBlob), v)) + }, + ) +} + +// BlobGTE applies the GTE predicate on the "blob" field. +func BlobGTE(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldBlob), v)) + }, + ) +} + +// BlobLT applies the LT predicate on the "blob" field. +func BlobLT(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldBlob), v)) + }, + ) +} + +// BlobLTE applies the LTE predicate on the "blob" field. +func BlobLTE(v []byte) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldBlob), v)) + }, + ) +} + // BlobIsNil applies the IsNil predicate on the "blob" field. func BlobIsNil() predicate.User { return predicate.User( @@ -1035,6 +1035,80 @@ func BlobNotNil() predicate.User { ) } +// StateEQ applies the EQ predicate on the "state" field. +func StateEQ(v State) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldState), v)) + }, + ) +} + +// StateNEQ applies the NEQ predicate on the "state" field. +func StateNEQ(v State) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldState), v)) + }, + ) +} + +// StateIn applies the In predicate on the "state" field. +func StateIn(vs ...State) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldState), v...)) + }, + ) +} + +// StateNotIn applies the NotIn predicate on the "state" field. +func StateNotIn(vs ...State) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User( + func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldState), v...)) + }, + ) +} + +// StateIsNil applies the IsNil predicate on the "state" field. +func StateIsNil() predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldState))) + }, + ) +} + +// StateNotNil applies the NotNil predicate on the "state" field. +func StateNotNil() predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldState))) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { return predicate.User( diff --git a/entc/integration/migrate/entv2/user_create.go b/entc/integration/migrate/entv2/user_create.go index 7995be1c7..e664092bb 100644 --- a/entc/integration/migrate/entv2/user_create.go +++ b/entc/integration/migrate/entv2/user_create.go @@ -9,6 +9,7 @@ package entv2 import ( "context" "errors" + "fmt" "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/migrate/entv2/user" @@ -24,6 +25,7 @@ type UserCreate struct { title *string new_name *string blob *[]byte + state *user.State } // SetAge sets the age field. @@ -84,6 +86,20 @@ func (uc *UserCreate) SetBlob(b []byte) *UserCreate { return uc } +// SetState sets the state field. +func (uc *UserCreate) SetState(u user.State) *UserCreate { + uc.state = &u + return uc +} + +// SetNillableState sets the state field if the given value is not nil. +func (uc *UserCreate) SetNillableState(u *user.State) *UserCreate { + if u != nil { + uc.SetState(*u) + } + return uc +} + // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { if uc.age == nil { @@ -103,6 +119,11 @@ func (uc *UserCreate) Save(ctx context.Context) (*User, error) { v := user.DefaultTitle uc.title = &v } + if uc.state != nil { + if err := user.StateValidator(*uc.state); err != nil { + return nil, fmt.Errorf("entv2: validator failed for field \"state\": %v", err) + } + } return uc.sqlSave(ctx) } @@ -153,6 +174,10 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { builder.Set(user.FieldBlob, *value) u.Blob = *value } + if value := uc.state; value != nil { + builder.Set(user.FieldState, *value) + u.State = *value + } query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { return nil, rollback(tx, err) diff --git a/entc/integration/migrate/entv2/user_update.go b/entc/integration/migrate/entv2/user_update.go index 893c55c9b..70025a05f 100644 --- a/entc/integration/migrate/entv2/user_update.go +++ b/entc/integration/migrate/entv2/user_update.go @@ -28,6 +28,8 @@ type UserUpdate struct { clearnew_name bool blob *[]byte clearblob bool + state *user.State + clearstate bool predicates []predicate.User } @@ -120,8 +122,34 @@ func (uu *UserUpdate) ClearBlob() *UserUpdate { return uu } +// SetState sets the state field. +func (uu *UserUpdate) SetState(u user.State) *UserUpdate { + uu.state = &u + return uu +} + +// SetNillableState sets the state field if the given value is not nil. +func (uu *UserUpdate) SetNillableState(u *user.State) *UserUpdate { + if u != nil { + uu.SetState(*u) + } + return uu +} + +// ClearState clears the value of state. +func (uu *UserUpdate) ClearState() *UserUpdate { + uu.state = nil + uu.clearstate = true + return uu +} + // Save executes the query and returns the number of rows/vertices matched by this operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { + if uu.state != nil { + if err := user.StateValidator(*uu.state); err != nil { + return 0, fmt.Errorf("entv2: validator failed for field \"state\": %v", err) + } + } return uu.sqlSave(ctx) } @@ -208,6 +236,12 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if uu.clearblob { builder.SetNull(user.FieldBlob) } + if value := uu.state; value != nil { + builder.Set(user.FieldState, *value) + } + if uu.clearstate { + builder.SetNull(user.FieldState) + } if !builder.Empty() { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { @@ -234,6 +268,8 @@ type UserUpdateOne struct { clearnew_name bool blob *[]byte clearblob bool + state *user.State + clearstate bool } // SetAge sets the age field. @@ -319,8 +355,34 @@ func (uuo *UserUpdateOne) ClearBlob() *UserUpdateOne { return uuo } +// SetState sets the state field. +func (uuo *UserUpdateOne) SetState(u user.State) *UserUpdateOne { + uuo.state = &u + return uuo +} + +// SetNillableState sets the state field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableState(u *user.State) *UserUpdateOne { + if u != nil { + uuo.SetState(*u) + } + return uuo +} + +// ClearState clears the value of state. +func (uuo *UserUpdateOne) ClearState() *UserUpdateOne { + uuo.state = nil + uuo.clearstate = true + return uuo +} + // Save executes the query and returns the updated entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { + if uuo.state != nil { + if err := user.StateValidator(*uuo.state); err != nil { + return nil, fmt.Errorf("entv2: validator failed for field \"state\": %v", err) + } + } return uuo.sqlSave(ctx) } @@ -422,6 +484,15 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (u *User, err error) { u.Blob = value builder.SetNull(user.FieldBlob) } + if value := uuo.state; value != nil { + builder.Set(user.FieldState, *value) + u.State = *value + } + if uuo.clearstate { + var value user.State + u.State = value + builder.SetNull(user.FieldState) + } if !builder.Empty() { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { diff --git a/entc/integration/migrate/migrate_test.go b/entc/integration/migrate/migrate_test.go index 4e02a41ec..33855195a 100644 --- a/entc/integration/migrate/migrate_test.go +++ b/entc/integration/migrate/migrate_test.go @@ -12,6 +12,7 @@ import ( "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/migrate/entv1" migratev1 "github.com/facebookincubator/ent/entc/integration/migrate/entv1/migrate" + userv1 "github.com/facebookincubator/ent/entc/integration/migrate/entv1/user" "github.com/facebookincubator/ent/entc/integration/migrate/entv2" migratev2 "github.com/facebookincubator/ent/entc/integration/migrate/entv2/migrate" "github.com/facebookincubator/ent/entc/integration/migrate/entv2/user" @@ -93,7 +94,7 @@ func SanityV1(t *testing.T, client *entv1.Client) { require.Error(t, err, "name is limited to 10 chars") // unique index on (name, address). - client.User.Create().SetAge(3).SetName("foo").SetAddress("tlv").SaveX(ctx) + client.User.Create().SetAge(3).SetName("foo").SetAddress("tlv").SetState(userv1.StateLoggedIn).SaveX(ctx) _, err = client.User.Create().SetAge(4).SetName("foo").SetAddress("tlv").Save(ctx) require.Error(t, err) @@ -102,18 +103,28 @@ func SanityV1(t *testing.T, client *entv1.Client) { require.Equal(t, "hello", string(u.Blob)) u, err = u.Update().SetBlob(make([]byte, 256)).Save(ctx) require.Error(t, err, "data too long for column 'blob' error") + + // invalid enum value. + _, err = client.User.Create().SetAge(1).SetName("bar").SetState(userv1.State("unknown")).Save(ctx) + require.Error(t, err) } func SanityV2(t *testing.T, client *entv2.Client) { ctx := context.Background() - u := client.User.Create().SetAge(1).SetName("bar").SetPhone("100").SaveX(ctx) + u := client.User.Create().SetAge(1).SetName("bar").SetPhone("100").SetState(user.StateLoggedOut).SaveX(ctx) require.Equal(t, 1, u.Age) require.Equal(t, "bar", u.Name) require.Equal(t, []byte("{}"), u.Buffer) u = u.Update().SetBuffer([]byte("[]")).SaveX(ctx) require.Equal(t, []byte("[]"), u.Buffer) + require.Equal(t, user.StateLoggedOut, u.State) - _, err := client.User.Create().SetAge(1).SetName("foobarbazqux").SetPhone("200").Save(ctx) + _, err := u.Update().SetState(user.State("boring")).Save(ctx) + require.Error(t, err, "invalid enum value") + u = u.Update().SetState(user.StateOnline).SaveX(ctx) + require.Equal(t, user.StateOnline, u.State) + + _, err = client.User.Create().SetAge(1).SetName("foobarbazqux").SetPhone("200").Save(ctx) require.NoError(t, err, "name is not limited to 10 chars") // new unique index was added to (age, phone). @@ -129,7 +140,7 @@ func SanityV2(t *testing.T, client *entv2.Client) { ) // blob type was extended. - u, err = u.Update().SetBlob(make([]byte, 256)).Save(ctx) + u, err = u.Update().SetBlob(make([]byte, 256)).SetState(user.StateLoggedOut).Save(ctx) require.NoError(t, err, "data type blob was extended in v2") require.Equal(t, make([]byte, 256), u.Blob) } diff --git a/entc/integration/template/ent/group/where.go b/entc/integration/template/ent/group/where.go index 7b68375e8..5f708cdc2 100644 --- a/entc/integration/template/ent/group/where.go +++ b/entc/integration/template/ent/group/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.Group { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Group { return predicate.Group( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.Group { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // MaxUsers applies equality check predicate on the "max_users" field. It's identical to MaxUsersEQ. func MaxUsers(v int) predicate.Group { return predicate.Group( @@ -139,42 +139,6 @@ func MaxUsersNEQ(v int) predicate.Group { ) } -// MaxUsersGT applies the GT predicate on the "max_users" field. -func MaxUsersGT(v int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMaxUsers), v)) - }, - ) -} - -// MaxUsersGTE applies the GTE predicate on the "max_users" field. -func MaxUsersGTE(v int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMaxUsers), v)) - }, - ) -} - -// MaxUsersLT applies the LT predicate on the "max_users" field. -func MaxUsersLT(v int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMaxUsers), v)) - }, - ) -} - -// MaxUsersLTE applies the LTE predicate on the "max_users" field. -func MaxUsersLTE(v int) predicate.Group { - return predicate.Group( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMaxUsers), v)) - }, - ) -} - // MaxUsersIn applies the In predicate on the "max_users" field. func MaxUsersIn(vs ...int) predicate.Group { v := make([]interface{}, len(vs)) @@ -213,6 +177,42 @@ func MaxUsersNotIn(vs ...int) predicate.Group { ) } +// MaxUsersGT applies the GT predicate on the "max_users" field. +func MaxUsersGT(v int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMaxUsers), v)) + }, + ) +} + +// MaxUsersGTE applies the GTE predicate on the "max_users" field. +func MaxUsersGTE(v int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMaxUsers), v)) + }, + ) +} + +// MaxUsersLT applies the LT predicate on the "max_users" field. +func MaxUsersLT(v int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMaxUsers), v)) + }, + ) +} + +// MaxUsersLTE applies the LTE predicate on the "max_users" field. +func MaxUsersLTE(v int) predicate.Group { + return predicate.Group( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMaxUsers), v)) + }, + ) +} + // And groups list of predicates with the AND operator between them. func And(predicates ...predicate.Group) predicate.Group { return predicate.Group( diff --git a/entc/integration/template/ent/pet/where.go b/entc/integration/template/ent/pet/where.go index e3990e82e..077b9adb9 100644 --- a/entc/integration/template/ent/pet/where.go +++ b/entc/integration/template/ent/pet/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.Pet { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Pet { return predicate.Pet( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.Pet { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // Age applies equality check predicate on the "age" field. It's identical to AgeEQ. func Age(v int) predicate.Pet { return predicate.Pet( @@ -139,42 +139,6 @@ func AgeNEQ(v int) predicate.Pet { ) } -// AgeGT applies the GT predicate on the "age" field. -func AgeGT(v int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAge), v)) - }, - ) -} - -// AgeGTE applies the GTE predicate on the "age" field. -func AgeGTE(v int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAge), v)) - }, - ) -} - -// AgeLT applies the LT predicate on the "age" field. -func AgeLT(v int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAge), v)) - }, - ) -} - -// AgeLTE applies the LTE predicate on the "age" field. -func AgeLTE(v int) predicate.Pet { - return predicate.Pet( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAge), v)) - }, - ) -} - // AgeIn applies the In predicate on the "age" field. func AgeIn(vs ...int) predicate.Pet { v := make([]interface{}, len(vs)) @@ -213,6 +177,42 @@ func AgeNotIn(vs ...int) predicate.Pet { ) } +// AgeGT applies the GT predicate on the "age" field. +func AgeGT(v int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldAge), v)) + }, + ) +} + +// AgeGTE applies the GTE predicate on the "age" field. +func AgeGTE(v int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldAge), v)) + }, + ) +} + +// AgeLT applies the LT predicate on the "age" field. +func AgeLT(v int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldAge), v)) + }, + ) +} + +// AgeLTE applies the LTE predicate on the "age" field. +func AgeLTE(v int) predicate.Pet { + return predicate.Pet( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldAge), v)) + }, + ) +} + // HasOwner applies the HasEdge predicate on the "owner" edge. func HasOwner() predicate.Pet { return predicate.Pet( diff --git a/entc/integration/template/ent/user/where.go b/entc/integration/template/ent/user/where.go index 88c652bd7..e8768747b 100644 --- a/entc/integration/template/ent/user/where.go +++ b/entc/integration/template/ent/user/where.go @@ -38,42 +38,6 @@ func IDNEQ(id int) predicate.User { ) } -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }, - ) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }, - ) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }, - ) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }, - ) -} - // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.User { return predicate.User( @@ -112,6 +76,42 @@ func IDNotIn(ids ...int) predicate.User { ) } +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldID), id)) + }, + ) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldID), id)) + }, + ) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldID), id)) + }, + ) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }, + ) +} + // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.User { return predicate.User( @@ -139,42 +139,6 @@ func NameNEQ(v string) predicate.User { ) } -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }, - ) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }, - ) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }, - ) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }, - ) -} - // NameIn applies the In predicate on the "name" field. func NameIn(vs ...string) predicate.User { v := make([]interface{}, len(vs)) @@ -213,6 +177,42 @@ func NameNotIn(vs ...string) predicate.User { ) } +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldName), v)) + }, + ) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldName), v)) + }, + ) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldName), v)) + }, + ) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User( + func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldName), v)) + }, + ) +} + // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.User { return predicate.User( diff --git a/entc/load/internal/bindata.go b/entc/load/internal/bindata.go index 9ba073d2e..59f76e958 100644 --- a/entc/load/internal/bindata.go +++ b/entc/load/internal/bindata.go @@ -98,7 +98,7 @@ func templateMainTmpl() (*asset, error) { return a, nil } -var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x5f\x6f\xe3\x38\x0e\x7f\x8e\x3f\x05\x27\xc0\x14\x76\x91\x75\xe6\xf6\xed\x32\xc8\xc3\x62\xb6\x0b\xf4\xf6\xa6\x33\xd8\xf6\xee\xa5\x28\xba\x8e\x4d\x25\x9a\xda\xb2\x47\x52\x3a\xcd\x16\xfd\xee\x07\x8a\x92\xff\xc4\x49\x6f\xfe\x6c\xfb\x52\x8b\x22\x29\xf2\x47\x8a\xa4\x32\x9f\xc3\xbb\xba\xd9\x69\xb9\xde\x58\xf8\xf9\xcd\x3f\xfe\xf9\x53\xa3\xd1\xa0\xb2\xf0\x5b\x96\xe3\xaa\xae\xef\xe0\x5c\xe5\x29\xfc\x52\x96\xe0\x98\x0c\xd0\xbe\xbe\xc7\x22\x8d\xe6\x73\xb8\xda\x48\x03\xa6\xde\xea\x1c\x21\xaf\x0b\x04\x69\xa0\x94\x39\x2a\x83\x05\x6c\x55\x81\x1a\xec\x06\xe1\x97\x26\xcb\x37\x08\x3f\xa7\x6f\xc2\x2e\x88\x7a\xab\x0a\x52\x21\x95\x63\xf9\xf7\xf9\xbb\xb3\x8b\xcb\x33\x10\xb2\xc4\x40\xd3\x75\x6d\xa1\x90\x1a\x73\x5b\xeb\x1d\xd4\x02\x6c\xef\x3c\xab\x11\xd3\x28\x6a\xb2\xfc\x2e\x5b\x23\x94\x75\x56\x44\x91\xac\x9a\x5a\x5b\x88\xa3\xc9\x14\x55\x5e\x17\x52\xad\xe7\x9f\x4c\xad\xa6\xd1\x64\x2a\x2a\x4b\xff\x34\x8a\x12\x73\x3b\x8d\xa2\xc9\x74\x2d\xed\x66\xbb\x4a\xf3\xba\x9a\x0b\xef\xb0\x54\xf9\x76\x95\xd9\x5a\xcf\x51\xd9\xb9\xc9\x37\x58\x65\x73\x2c\xd6\xf8\x55\x02\xd3\x6f\x50\x2a\x24\x96\xc5\x34\x4a\x22\x82\xe1\xd2\xd1\x40\xa3\x0f\x80\x81\x4c\x01\x2a\x9b\xfa\x0d\xbb\xc9\x2c\x7c\xc9\x8c\xf3\x13\x0b\x10\xba\xae\x20\x83\xbc\xae\x9a\x52\x12\xd8\x06\x35\x78\x2c\xd2\xc8\xee\x1a\x0c\x2a\x8d\xd5\xdb\xdc\xc2\x63\x34\xb9\xc8\x2a\x84\xf0\x67\xac\x96\x6a\xdd\x2e\xff\x24\x94\x16\x53\x95\x55\x38\xab\x2b\x69\xb1\x6a\xec\x6e\xfa\x67\x34\x79\x57\x2b\x21\x03\x1f\x19\xd4\x23\x78\xa1\xdc\x51\x86\x62\x67\xc5\x1a\x4d\x50\x7e\x7d\x73\x4a\xeb\xbd\xb3\x08\x54\x33\x94\xfa\x8d\x20\x31\x9d\x94\x5b\x0f\xa5\x1c\x6a\x7b\x62\xe7\xaa\xc0\x87\x70\xdc\xf5\xcd\xa9\x5b\x0f\xc5\x24\xb3\x0c\xe5\x2e\x1d\x34\xfe\xd0\xeb\x9b\xd3\xde\x3a\xc8\x31\x7a\xb7\x07\x4e\x7d\x72\x71\xfb\x58\x1b\x69\x65\xad\xa0\x40\x93\x6b\xb9\x42\x03\x19\x38\x6e\x68\xc2\x96\x4f\x67\x0e\xbb\x0f\x4e\x2b\xd7\x85\xa7\x67\xb5\x54\x16\x60\x3e\xf7\x8a\x9c\xed\x41\x0b\x93\x4a\x69\x6c\x1a\x4d\xde\xcb\x07\x2c\xce\x15\x89\xac\xea\xba\x04\x77\x9f\x0a\x99\x67\x16\x0d\x48\xd1\x13\xa0\xd4\xa9\x88\xfb\x27\xa9\x58\x50\xaa\x73\xaf\x97\xcf\xaa\x88\x34\x3c\x8b\x49\x7c\x16\xbb\xcb\xd8\x8c\xb3\x94\xe9\xdf\x91\xa4\x2c\x78\x24\x47\xf7\x93\xf4\x78\x96\x9e\x2b\x51\x77\x6c\xa7\xce\xe7\xf4\x6a\xd7\xa0\xdb\xf0\x62\x74\xe0\x50\xec\x2a\xeb\x29\x3f\x76\x9a\xcd\xf6\x72\xfb\x52\xfe\xd5\xb3\xf1\xd4\x01\x38\x92\x32\xf2\xaf\xbd\xc3\xfe\xa3\xe4\xe7\x6d\x2b\xe8\xe2\x35\x16\xdb\x3a\xa6\xa1\xe0\x85\x2c\xcb\x6c\x55\xe2\xb3\x82\xca\x33\x0d\x45\x3f\x34\x94\x64\x59\xf9\xac\x68\xed\x99\x86\xa2\xbf\xa2\xc8\xb6\xa5\x7d\xde\xdc\x82\x99\xf6\x1c\x6d\x8a\xcc\x62\x90\x3f\xe6\xa8\x63\xba\x3d\xa8\xe0\xbc\xaa\xb6\xb6\xf5\xf8\x88\x02\x19\x98\x86\xb2\xff\xcd\x4a\x59\x50\xa9\x35\xed\x45\x1a\xcb\xde\xb7\x4c\xfb\x05\xa1\xd6\xd9\x1a\x7f\xc7\xdd\x33\xf9\x60\x98\xe9\xf6\x0e\x77\x43\xe9\xf6\x4e\x73\x5e\x0c\x97\x41\x3a\x54\x85\x03\xb5\xa4\x5f\x7e\xf6\xae\xd8\x83\x45\x4d\x61\xf4\x17\x85\xef\x74\x81\x42\x2a\x2c\x0e\xd6\x97\xbe\xae\xee\x76\xb5\xf9\xee\x5d\x3b\x96\xe1\xed\x2d\x1c\xf2\x8d\xef\x1d\x5d\xb1\x43\x0a\x47\x37\xed\x5d\x5d\x55\x34\x57\xec\x31\xe6\x4c\xde\xc3\xf1\x6e\xfd\x31\xb3\x9b\x7d\xde\xe6\x6e\x7d\xdb\x64\x76\xb3\xd7\x68\xaa\x15\x16\x54\x6c\x7c\x9a\x84\xe6\xe2\xc9\x07\x60\x76\xad\x68\x5c\xc2\x1c\xf9\x3b\x2a\x98\x93\x3b\x50\xc0\xfe\x36\xe8\xbe\x36\x68\x7f\xa0\xe0\xc3\x87\x7c\x1a\xc5\xed\xf8\xf4\x3f\x50\xf8\x34\xe5\xce\xdc\x31\x1f\x29\x5a\x43\x78\x0f\x95\xa9\x73\x75\x8f\xda\xe0\x3e\xab\x64\xf2\xfe\xf1\x9f\xb7\x52\x8f\xa2\xa6\x3d\xf9\x40\xd4\xb8\x59\x8d\xc3\xc6\xf4\xef\x88\x1b\x0b\x76\x81\xf3\x9e\xb6\xd5\xe6\x19\x4f\xfd\x70\x73\x7d\x33\x44\xfa\xf8\x40\xb3\xcf\x79\x74\x9c\xb8\xc0\x2f\x2e\x1e\xb9\x46\xd7\xc3\x33\x15\x3c\x22\xe5\xec\x96\xfb\xe2\x71\xa3\xb1\xb5\x4e\x23\xb1\x55\x79\x90\x8c\xb1\x80\x53\xe2\x48\x7f\x6d\x39\x12\x1f\xe4\xc7\x68\xa2\x10\x16\x4b\x38\xa1\xe5\x63\x34\xa1\xd4\x5a\x70\x1a\x60\x91\x5e\x65\xeb\x19\xd1\x76\x0d\x2e\x5a\x1a\x65\x63\x34\x71\x59\xdd\x12\x69\x41\x44\x46\x6c\xc1\x44\x5e\x10\xd9\xe7\xc1\xc2\x91\xfd\x82\xe8\x21\xe6\x0b\xa2\x87\x05\x6f\x08\xaf\xdf\x6d\x08\xaf\xff\x29\x9a\x48\x01\x1a\x05\x99\xcc\x3b\x6f\xdd\xf2\xd5\x12\x94\x2c\xc9\x9d\x89\x42\x22\xc3\xb2\x75\x5f\xa3\x48\x9c\xa8\x46\xbb\xd5\x0a\x14\x76\xc8\x72\x35\x1c\x43\xcb\xd5\xf4\x79\x6c\x9d\x6c\x2c\x8a\x30\x5b\xf4\xd1\x8d\x79\x4e\x9d\x01\x6a\x4d\xeb\xc7\x68\x62\x9c\xd1\x27\x8e\xfe\x38\xc0\xcf\xfd\x89\x0e\x44\x1a\x50\x86\x3b\x44\x99\x0d\x82\x13\x76\x7c\x84\x3a\xdc\xc3\x46\x07\x7e\x98\x15\x16\xdd\x41\x61\x30\x88\x26\xed\x38\xd0\xed\x06\x8a\x33\x25\x74\xd4\x45\x6b\x4a\xdb\x63\xa3\x49\xaf\x39\x2e\xfc\x76\x47\xa1\xfd\xae\xf3\xba\xfd\x12\x55\x2c\x8a\xb4\xa3\x26\xc4\xe4\xa7\x82\x45\x67\x7b\x98\x13\x38\xaa\xce\xbf\xfe\xfc\xb0\x70\xfe\x0d\x26\x8a\x96\x93\x33\xc4\x08\x07\x19\x2c\xbb\xb4\x08\xc1\x97\xe5\x0c\x44\x65\xd3\x33\x0a\x8c\x88\xa7\x95\x34\x86\xae\xa1\x2b\x00\x92\x84\x44\xad\x7d\xfc\x5f\x7f\x9e\xce\x48\x17\x05\x26\x09\xba\xc9\x49\x9a\xf6\x5e\x2d\xe1\x8d\xd3\x6c\x04\x13\x96\x70\xe2\xf7\xfa\xd9\x66\xc4\x8c\x0e\xf5\x29\xf7\x3e\xd3\x66\x93\x95\xfe\x1d\xe6\xde\xa3\xe8\x3a\x75\xef\x5d\x27\x95\x45\x4d\xcf\x44\xfa\xaa\x21\x83\x7f\x5d\x7e\xb8\x20\x61\x57\xd1\xf2\x4c\xc1\x8a\x12\x92\x44\x0b\x66\x21\x05\x5e\xb8\x5e\x7d\xc2\xdc\xfa\x7f\x3e\x57\x07\x87\xc6\x26\x9c\x4d\x85\xd2\x9f\x94\x40\xbc\x82\xeb\x9b\xd5\xce\xa2\x4b\xd9\x7e\xda\xba\xac\x65\x59\xf2\x96\xdf\x7a\x8b\x30\x5a\xf0\x32\x4e\xfa\x15\x81\xde\x1b\xf4\x42\x8f\xfd\xbb\xda\x95\x8c\x0f\xc2\x9f\x9c\x24\x0e\x4f\x27\xc2\x88\xd2\x81\x8b\x25\x98\x94\x2e\x1f\x97\xc7\xc0\xfb\xd6\x6d\xbe\x3a\x1c\x46\xd4\xda\xa9\xe0\x22\xdb\xaa\xc9\x04\xba\x6a\x1c\x74\xb4\x67\x1c\x51\xd3\xcf\x06\x0f\xce\xeb\xcf\x0b\x78\x7d\x4f\xc1\xe7\x4b\x49\xe2\x9c\x00\x94\x1c\xb7\x33\x70\x35\x53\x67\x6a\x8d\xae\x3e\x18\x4e\x84\x94\xbb\xc0\x12\xb2\xa6\x41\x55\xc4\x9e\x30\xeb\x2a\x71\xaf\x48\xc4\x49\xe2\x73\xca\xbf\x43\xfb\x0e\xf8\xe7\xeb\x4b\xba\x20\x8b\x87\xce\x09\x6f\x83\x53\xec\x37\x64\xf1\x30\xb0\xd6\x39\x18\x9e\xd5\x3d\x17\xcf\x83\xf9\x27\xee\x8b\x34\x70\x37\x5c\x80\xd3\xc1\x10\x10\x95\x43\xbb\x70\x54\xfe\x76\xe4\x50\xbb\x88\xdc\x55\xad\xa7\x41\xcd\xa6\x1e\x99\xfa\x3c\x8e\x4d\xe2\x6f\x53\x97\x2f\xee\xd3\xf8\x6b\x6b\x6b\x9f\x9d\xbe\x80\xf7\x33\xdd\x5f\x89\xd8\xc0\x29\xe7\x74\x02\xa3\xac\xdb\xbf\x1b\xee\x32\x10\x34\xee\xf1\x3b\x88\x93\x7b\x34\x7f\x45\x94\xbe\x39\x40\x72\x06\x55\x2f\x3e\xfc\xec\x26\x85\x7e\x4e\xe8\x1b\xe1\x8d\xaf\x1e\x28\x46\x63\x13\xbe\xdd\x06\x32\xc2\x59\xf1\x69\x06\xa2\x33\x82\x8f\x66\x9d\x54\xd6\xbc\x09\x5d\x2b\x1c\x66\x37\xb1\x1d\xb0\xe6\x3b\xcc\x71\xf6\x50\x9d\x6d\xdf\x4f\x4b\x38\x09\xdf\xac\xd4\xe5\x9e\x6f\x21\x9f\x5c\x5a\x85\x5f\x42\x1c\xd1\x6a\xce\xaa\x49\xef\x67\x8e\x05\xc8\x59\xa7\xdc\x67\x64\x3f\xb3\x7d\x8e\x82\x11\x1e\x13\x8a\xcd\x51\xf8\x5f\x26\x09\x0e\xc3\xff\x75\xe8\xff\x6d\xa9\x70\x0c\xf9\x00\xa3\xe3\xf9\x7f\x00\xf6\x06\xb0\xb6\x1d\x76\xf0\xc1\x17\x9d\x35\xa6\xff\x68\xf5\xf4\x4c\x15\x9c\xfd\x81\x50\xa1\xdd\xd4\x05\x7c\x91\x76\x03\x1a\xf3\xfa\x1e\x35\xdd\x78\x54\x66\xab\x11\x54\x0d\x4d\xa6\x64\x6e\xe8\x09\x5c\x71\xc1\x90\x6a\xed\xaf\x7d\x2f\x5c\xa2\xe8\x1a\xed\x23\x78\x62\x02\xd7\x37\xdd\x6f\x57\x4f\x09\xc4\x22\x4c\xeb\x2d\x79\xbf\x41\x16\x28\x50\x03\xa9\x8f\x13\xae\x9f\x02\xee\x5d\xd4\xd8\xb8\x38\x79\x0b\xf7\x83\x20\x90\xfc\x72\x10\x83\xd7\x57\xc1\x3b\x36\xde\x87\x42\x14\x33\xb8\x77\x17\x40\x04\x6c\x09\x3b\xce\x45\xaa\xc8\x21\x9c\x45\x1a\x1c\x98\xed\xa1\xcb\x1d\x69\x04\x2e\x93\x7f\x14\xca\x7e\x9b\x1d\x0d\x14\xdc\x17\x19\x38\x62\x7c\x09\xdc\x06\xde\x0c\xa0\x63\xd8\xd0\xf7\xe3\x83\xa8\xf5\x85\xc7\xc0\x85\x4e\x37\x82\x2e\x6c\xfc\x28\x78\xc3\x16\x3f\x82\x2f\x74\x64\x06\xd0\x31\xbf\x20\x82\xc1\xa9\x03\x18\xca\xb6\xe5\x3f\x87\x62\xf0\x66\x84\xa3\xab\xb7\x63\x14\x99\xfc\xa3\x18\xf6\xdb\xef\x08\x41\xee\x99\x8c\xdf\xfb\xae\x73\xbf\x08\x7e\xec\xce\x01\xf4\xd8\x88\xe7\xb1\x63\x2f\x3a\xe4\x9c\x7b\xed\x10\x6d\xa1\x3f\x46\x27\x83\x15\x59\x45\x8d\xc2\xa6\xbf\x4b\x55\xc4\x09\x3d\x78\xc2\xfe\x47\xeb\x66\x96\x89\x85\x25\xd8\xf4\xac\xc4\x2a\x1e\x54\x61\x1b\x3d\x45\xff\x0b\x00\x00\xff\xff\xc4\x50\x96\x40\xed\x1b\x00\x00") +var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x5b\x6f\xe3\xb8\xee\x7f\x8e\x3f\x05\x27\xc0\x0c\xe2\x22\xeb\xcc\x7f\xdf\xfe\x1e\xe4\x61\x31\xdb\x05\x7a\xf6\xcc\x05\xdb\x9e\xf3\x52\x14\x5d\xc7\xa6\x12\x4d\x6d\xd9\x23\x29\x9d\x76\x8b\x7e\xf7\x03\x52\x92\xaf\x49\x77\x2e\xdb\xbe\xd4\xa2\x48\x8a\xfc\x91\x22\xa9\xac\x56\xf0\xb6\x6e\xee\xb5\xdc\xee\x2c\xfc\xfc\xfa\xff\xfe\xff\xa7\x46\xa3\x41\x65\xe1\xb7\x2c\xc7\x4d\x5d\xdf\xc0\x99\xca\x13\xf8\xa5\x2c\x81\x99\x0c\xd0\xbe\xbe\xc5\x22\x89\x56\x2b\xb8\xd8\x49\x03\xa6\xde\xeb\x1c\x21\xaf\x0b\x04\x69\xa0\x94\x39\x2a\x83\x05\xec\x55\x81\x1a\xec\x0e\xe1\x97\x26\xcb\x77\x08\x3f\x27\xaf\xc3\x2e\x88\x7a\xaf\x0a\x52\x21\x15\xb3\xfc\xfb\xec\xed\xe9\xfb\xf3\x53\x10\xb2\xc4\x40\xd3\x75\x6d\xa1\x90\x1a\x73\x5b\xeb\x7b\xa8\x05\xd8\xde\x79\x56\x23\x26\x51\xd4\x64\xf9\x4d\xb6\x45\x28\xeb\xac\x88\x22\x59\x35\xb5\xb6\xb0\x88\x66\x73\x54\x79\x5d\x48\xb5\x5d\x7d\x32\xb5\x9a\x47\xb3\xb9\xa8\x2c\xfd\xd3\x28\x4a\xcc\xed\x3c\x8a\x66\xf3\xad\xb4\xbb\xfd\x26\xc9\xeb\x6a\x25\xbc\xc3\x52\xe5\xfb\x4d\x66\x6b\xbd\x42\x65\x57\x26\xdf\x61\x95\xad\xb0\xd8\xe2\x57\x09\xcc\xbf\x41\xa9\x90\x58\x16\xf3\x28\x8e\x08\x86\x73\xa6\x81\x46\x1f\x00\x03\x99\x02\x54\x36\xf1\x1b\x76\x97\x59\xf8\x92\x19\xf6\x13\x0b\x10\xba\xae\x20\x83\xbc\xae\x9a\x52\x12\xd8\x06\x35\x78\x2c\x92\xc8\xde\x37\x18\x54\x1a\xab\xf7\xb9\x85\x87\x68\xf6\x3e\xab\x10\xc2\x9f\xb1\x5a\xaa\x6d\xbb\xfc\x93\x50\x4a\xe7\x2a\xab\x70\x59\x57\xd2\x62\xd5\xd8\xfb\xf9\x9f\xd1\xec\x6d\xad\x84\x0c\x7c\x64\x50\x8f\xe0\x85\x72\xa6\x0c\xc5\x4e\x8b\x2d\x9a\xa0\xfc\xf2\xea\x84\xd6\xa3\xb3\x08\x54\x33\x94\xfa\x8d\x20\x31\x9d\x14\xaf\x87\x52\x8c\xda\x48\xec\x4c\x15\x78\x17\x8e\xbb\xbc\x3a\xe1\xf5\x50\x4c\x3a\x96\xa1\xdc\x39\x43\xe3\x0f\xbd\xbc\x3a\xe9\xad\x83\x9c\x43\xef\xfa\xc0\xa9\x8f\x1c\xb7\x8f\xb5\x91\x56\xd6\x0a\x0a\x34\xb9\x96\x1b\x34\x90\x01\x73\x43\x13\xb6\x7c\x3a\xbb\xb0\xfb\xe0\xb4\x72\x5d\x78\x7a\x56\x4b\x65\x01\x56\x2b\xaf\x88\x6d\x0f\x5a\x1c\xa9\x94\xc6\x26\xd1\xec\x9d\xbc\xc3\xe2\x4c\x91\xc8\xa6\xae\x4b\xe0\xfb\x54\xc8\x3c\xb3\x68\x40\x8a\x9e\x00\xa5\x4e\x45\xdc\x3f\x49\xe5\x04\xa5\x3a\xf3\x7a\xdd\x59\x15\x91\x86\x67\x39\x92\x3b\xcb\xb9\xeb\xb0\x99\x66\xa9\xa3\x7f\x47\x92\x3a\xc1\x23\x39\x3a\x4e\xd2\xe3\x59\x7a\xa6\x44\xdd\xb1\x9d\xb0\xcf\xc9\xc5\x7d\x83\xbc\xe1\xc5\xe8\xc0\xa1\xd8\x45\xd6\x53\x7e\xec\x34\x9b\x8d\x72\xfb\x5c\xfe\xd5\xb3\xf1\x84\x01\x9c\x48\x19\xf9\xd7\xe8\xb0\x53\xb5\xaf\xda\x2b\x01\x97\x57\xc3\xe3\xc2\xa5\x20\xa6\xa1\xdc\x7f\x94\xfc\xbc\x6f\x0f\xe4\x38\x4f\x8f\xdb\x33\xd3\x50\xf0\xbd\x2c\xcb\x6c\x53\xe2\x93\x82\xca\x33\x0d\x45\x3f\x34\x94\x9c\x59\xf9\xa4\x68\xed\x99\x86\xa2\xbf\xa2\xc8\xf6\xa5\x7d\xda\xdc\xc2\x31\x8d\x1c\x6d\x8a\xcc\x62\x90\x3f\xe6\x28\x33\x5d\x1f\x54\x70\x56\x55\x7b\xdb\x7a\x7c\x44\x81\x0c\x4c\x43\xd9\xff\x66\xa5\x2c\xa8\x44\x73\x88\x46\x31\x0d\xb2\xb7\x2d\xd3\xb8\x90\xd4\x3a\xdb\xe2\xef\x78\xff\x44\x1e\x19\xc7\x74\x7d\x83\xf7\x43\xe9\xb6\x16\xb8\x7c\x1a\x2e\x83\x74\xa8\x26\x07\x6a\x50\xbf\x6c\x8d\xae\xe6\x9d\x45\x4d\x61\xf4\x17\xcc\xd5\x82\x02\x85\x54\x58\x1c\xac\x4b\x7d\x5d\xdd\xad\x6c\xef\x89\x77\xed\xd8\xcd\x68\x6f\xef\x90\x6f\x7a\x5f\xe9\x6a\x1e\x52\x38\xb9\xa1\x6f\xeb\xaa\xa2\x79\x64\xc4\x98\x3b\xf2\x08\xc7\x9b\xed\xc7\xcc\xee\xc6\xbc\xcd\xcd\xf6\xba\xc9\xec\x6e\x74\x1b\xab\x0d\x16\x54\xa4\x7c\x9a\x84\xfb\xe7\xc9\x07\x60\xe6\x16\x36\x2d\x7d\x4c\xfe\x8e\xca\xc7\x72\x07\x0a\xdf\x3f\x06\xdd\xd7\x06\xed\x0f\x14\xee\xf0\x21\x9f\x46\x71\x3d\x3d\xfd\x0f\x14\x3e\x4d\x5d\x47\xef\x98\x8f\x14\xad\x21\xbc\x87\xca\xd4\x99\xba\x45\x6d\x70\xcc\x2a\x1d\x79\x7c\xfc\xe7\xbd\xd4\x93\xa8\x69\x4f\x3e\x10\x35\xd7\xe4\xa6\x61\x73\xf4\xef\x88\x9b\x13\xec\x02\xe7\x3d\x6d\xab\xcd\x13\x9e\xfa\xa1\xa8\x2d\xfd\x7f\x3b\x08\x8d\x39\x8f\x8e\x21\xef\xf1\x0b\xc7\x23\xd7\xc8\xbd\x3f\x53\xc1\x23\x52\xee\xdc\xe2\x2f\x37\xa6\x34\xb6\xd6\x49\x24\xf6\x2a\x0f\x92\x0b\x2c\xe0\x84\x38\x92\x5f\x5b\x8e\xd8\x07\xf9\x21\x9a\x29\x84\x74\x0d\xaf\x68\xf9\x10\xcd\x28\xb5\x52\x97\x06\x58\x24\x17\xd9\x76\x49\xb4\xfb\x06\xd3\x96\x46\xd9\x18\xcd\x38\xab\x5b\x22\x2d\x88\xe8\x10\x4b\x1d\xd1\x2d\x88\xec\xf3\x20\x65\xb2\x5f\x10\x3d\xc4\x3c\x25\x7a\x58\xb8\x0d\xe1\xf5\xf3\x86\xf0\xfa\x1f\xa3\x99\x14\xa0\x51\x90\xc9\x6e\xe7\x0d\x2f\x5f\xac\x41\xc9\x92\xdc\x99\x29\x24\x32\xac\x5b\xf7\x35\x8a\x98\x45\x35\xda\xbd\x56\xa0\xb0\x43\xd6\x55\xc3\x29\xb4\xae\x9a\x3e\x8d\x2d\xcb\x2e\x44\x11\x66\x92\x3e\xba\x0b\x37\xdf\x2e\x01\xb5\xa6\xf5\x43\x34\x33\x6c\xf4\x2b\xa6\x3f\x0c\xf0\xe3\x3f\xd1\x81\x48\x83\xcd\x70\x87\x28\xcb\x41\x70\xc2\x8e\x8f\x10\x0f\x20\x69\x7f\x83\x29\xc3\x90\x84\xad\x2e\x2e\x61\x8c\x48\x3b\x1b\xc2\xcc\x10\xcd\xda\x49\xa1\xdb\x0d\x14\xb6\x32\x34\xdb\xb4\xb5\xb2\x6d\xbf\xd1\xac\xd7\x37\x53\xbf\xdd\x51\x68\xbf\x6b\xca\xbc\x5f\xa2\x5a\x88\x22\xe9\xa8\x31\x31\xf9\x81\x21\xed\x6c\x0f\x23\x84\x0b\x38\xfb\xd7\x1f\x2d\x52\xf6\x6f\x30\x6c\xb4\x9c\x2e\x79\x8c\x60\x34\x61\xdd\x65\x4c\xc8\x0b\x59\x2e\x41\x54\x36\x39\xa5\x98\x89\xc5\xbc\x92\xc6\xd0\x0d\xe5\xda\x20\x49\x48\xd4\xda\xa7\xc6\xcb\xcf\xf3\x25\xe9\xa2\x98\xc5\x41\x37\x39\x49\x03\xe4\x8b\x35\xbc\x66\xcd\x46\x38\xc2\x1a\x5e\xf9\xbd\x7e\x22\x1a\xb1\xa4\x43\x7d\x36\xbe\xcb\xb4\xd9\x65\xa5\x7f\xda\xf1\x13\x17\xb9\x89\xf7\x9e\x8a\x52\x59\xd4\xf4\xf2\xa4\xaf\x1a\x32\xf8\xd7\xf9\x87\xf7\x24\xcc\xc5\x2e\xcf\x14\x6c\x28\x57\x49\xb4\x70\x2c\xa4\xc0\x0b\xd7\x9b\x4f\x98\x5b\xff\xcf\xa7\xf1\xe0\xd0\x85\x09\x67\x53\x0d\xf5\x27\xc5\xb0\xd8\xc0\xe5\xd5\xe6\xde\x22\x67\x73\x3f\xa3\x39\xa1\x9d\x2c\x79\xeb\x9e\x8f\x69\x98\x3a\xdc\x72\x11\xf7\x8b\x05\x3d\x61\xe8\xd1\xbf\xf0\x4f\x75\xae\x26\x1f\x84\x3f\x39\x8e\x19\x4f\x16\x71\x88\xd2\x81\xe9\x1a\x4c\x42\xf7\xd2\x55\xce\xc0\xfb\x86\x37\x5f\x1c\x0e\x23\x6a\xcd\x2a\x5c\xfd\x6d\xd5\x64\x02\xb9\x50\x07\x1d\xed\x19\x47\xd4\xf4\xb3\xc1\x83\xf3\xf2\x73\x0a\x2f\x6f\x29\xf8\xee\xbe\x92\xb8\x4b\x00\x4a\x8e\xeb\x25\x70\x39\xd5\x99\xda\x22\x97\x0e\xe3\x12\x21\x71\x0d\x62\x0d\x59\xd3\xa0\x2a\x16\x9e\xb0\xec\x8a\x74\xaf\x7e\x2c\xe2\xd8\xe7\x94\x7f\xda\xf6\x1d\xf0\x2f\xe2\xe7\x74\x41\x16\x77\x9d\x13\xde\x06\x56\xec\x37\x64\x71\x37\xb0\x96\x1d\x0c\x2f\xf5\x9e\x8b\x67\xc1\xfc\x57\xfc\x45\x1a\x5c\xa3\x4c\x81\x75\x38\x08\x88\xea\x42\x9b\x32\xd5\x7d\x33\x39\xd4\x2e\x22\x77\x55\xeb\x71\x50\xce\xa9\x7d\x26\x3e\x8f\x17\x26\xf6\xb7\xa9\xcb\x17\xfe\x34\xfe\xda\xda\xda\x67\xa7\xaf\xed\xfd\x4c\xf7\x57\x62\x61\xe0\xc4\xe5\x74\x0c\x93\xac\x1b\xdf\x0d\xbe\x0c\x04\x0d\xbf\xa7\x07\x71\xe2\x77\xf8\x57\x44\xe9\x9b\x03\x24\x97\x50\xf5\xe2\xe3\x5e\xf2\xa4\xd0\x8f\x10\x7d\x23\xbc\xf1\xd5\x1d\xc5\x68\x6a\xc2\xb7\xdb\x40\x46\xb0\x15\x9f\x96\x20\x3a\x23\xdc\xd1\x4e\x27\x95\x35\x6f\x42\xd7\x25\x87\xd9\x4d\x6c\x07\xac\xf9\x0e\x73\xd8\x1e\xaa\xb3\xed\xd3\x6a\x0d\xaf\xc2\xb7\x53\xca\xb9\xe7\x5b\xc8\x27\x4e\xab\xf0\xe3\x0a\x13\xad\x76\x59\x35\xeb\xfd\x72\x92\x82\x5c\x76\xca\x7d\x46\xf6\x33\xdb\xe7\x28\x18\xe1\x31\xa1\xd8\x1c\x85\xff\x79\x92\xe0\x30\xfc\x5f\x87\xfe\x3f\x96\x0a\xc7\x90\x0f\x30\x32\xcf\xdf\x01\xd8\x9b\xcd\xda\x76\xd8\xc1\x07\x5f\x74\xd6\x98\xfe\x7b\xd6\xd3\x33\x55\xb8\xec\x0f\x84\x0a\xed\xae\x2e\xe0\x8b\xb4\x3b\xd0\x98\xd7\xb7\xa8\xe9\xc6\xa3\x32\x7b\x8d\xa0\x6a\x68\x32\x25\x73\x43\xaf\xe3\xca\x15\x0c\xa9\xb6\xfe\xda\xf7\xc2\x25\x8a\xae\xd1\x3e\x80\x27\xc6\x70\x79\xd5\xfd\x1c\xf6\x18\xc3\x42\x84\x41\xbe\x25\x8f\x1b\x64\x81\x02\x35\x90\xfa\x45\xec\xea\xa7\x80\x5b\x8e\x9a\x33\x6e\x11\xbf\x81\xdb\x41\x10\x48\x7e\x3d\x88\xc1\xcb\x8b\xe0\x9d\x33\xde\x87\x42\x14\x4b\xb8\xe5\x0b\x20\x02\xb6\x84\x9d\xcb\x45\xaa\xc8\x21\x9c\x45\x12\x1c\x58\x8e\xd0\x75\x1d\x69\x02\xae\x23\xff\x28\x94\xfd\x36\x3b\x19\x28\x5c\x5f\x74\xc0\x11\xe3\x73\xe0\x36\xf0\x66\x00\x9d\x83\x0d\x7d\x3f\x3e\x88\x5a\x5f\x78\x0a\x5c\xe8\x74\x13\xe8\xc2\xc6\x8f\x82\x37\x6c\xf1\x13\xf8\x42\x47\x76\x00\x32\xf3\x33\x22\x18\x9c\x3a\x80\xa1\x6c\x5b\xfe\x53\x28\x06\x6f\x26\x38\x72\xbd\x9d\xa2\xe8\xc8\x3f\x8a\x61\xbf\xfd\x4e\x10\x74\x3d\xd3\xe1\xf7\xae\xeb\xdc\xcf\x82\x9f\x73\xe7\x00\x7a\xce\x88\xa7\xb1\x73\x5e\x74\xc8\xb1\x7b\xed\x10\x6d\xa1\x3f\x46\xc7\x83\x15\x59\x45\x8d\xc2\x26\xbf\x4b\x55\x2c\x62\x7a\xf0\x84\xfd\x8f\x96\x67\x96\x99\x85\x35\xd8\xe4\xb4\xc4\x6a\x31\xa8\xc2\x36\x7a\x8c\xfe\x17\x00\x00\xff\xff\x19\x89\xb5\x2a\x40\x1c\x00\x00") func schemaGoBytes() ([]byte, error) { return bindataRead( @@ -113,7 +113,7 @@ func schemaGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "schema.go", size: 7149, mode: os.FileMode(420), modTime: time.Unix(1569513414, 0)} + info := bindataFileInfo{name: "schema.go", size: 7232, mode: os.FileMode(420), modTime: time.Unix(1570012859, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/load/schema.go b/entc/load/schema.go index d2d9dddd6..99269963c 100644 --- a/entc/load/schema.go +++ b/entc/load/schema.go @@ -38,6 +38,7 @@ type Field struct { Info *field.TypeInfo `json:"type,omitempty"` Tag string `json:"tag,omitempty"` Size *int `json:"size,omitempty"` + Enums []string `json:"enums,omitempty"` Unique bool `json:"unique,omitempty"` Nillable bool `json:"nillable,omitempty"` Optional bool `json:"optional,omitempty"` @@ -101,6 +102,7 @@ func NewField(fd *field.Descriptor) (*Field, error) { Name: fd.Name, Info: fd.Info, Tag: fd.Tag, + Enums: fd.Enums, Unique: fd.Unique, Nillable: fd.Nillable, Optional: fd.Optional, diff --git a/entc/load/schema_test.go b/entc/load/schema_test.go index 683a7d645..58d3b001a 100644 --- a/entc/load/schema_test.go +++ b/entc/load/schema_test.go @@ -30,6 +30,9 @@ func (User) Fields() []ent.Field { Nillable(), field.String("optional"). Optional(), + field.Enum("state"). + Values("on", "off"). + Optional(), } } @@ -72,7 +75,7 @@ func TestMarshalSchema(t *testing.T) { schema := &Schema{} require.NoError(t, json.Unmarshal(buf, schema)) require.Equal(t, "User", schema.Name) - require.Len(t, schema.Fields, 4) + require.Len(t, schema.Fields, 5) require.Equal(t, "age", schema.Fields[0].Name) require.Equal(t, field.TypeInt, schema.Fields[0].Info.Type) @@ -89,6 +92,10 @@ func TestMarshalSchema(t *testing.T) { require.False(t, schema.Fields[3].Nillable) require.True(t, schema.Fields[3].Optional) + require.Equal(t, "state", schema.Fields[4].Name) + require.Equal(t, field.TypeEnum, schema.Fields[4].Info.Type) + require.Equal(t, []string{"on", "off"}, schema.Fields[4].Enums) + require.Len(t, schema.Edges, 2) require.Equal(t, "groups", schema.Edges[0].Name) require.Equal(t, "Group", schema.Edges[0].Type) diff --git a/schema/field/field.go b/schema/field/field.go index b5715f5c0..0e40d048b 100644 --- a/schema/field/field.go +++ b/schema/field/field.go @@ -26,6 +26,7 @@ type Descriptor struct { UpdateDefault interface{} // default value on update. Validators []interface{} // validator functions. StorageKey string // sql column or gremlin property. + Enums []string // enum values. } // String returns a new Field with type string. @@ -113,6 +114,22 @@ func Floats(name string) *jsonsBuilder { return JSON(name, []float64{}) } +// Enum returns a new Field with type enum. An example for defining enum is as follows: +// +// field.Enum("state"). +// Values( +// "on", +// "off", +// ). +// Default("on") +// +func Enum(name string) *enumBuilder { + return &enumBuilder{&Descriptor{ + Name: name, + Info: &TypeInfo{Type: TypeEnum}, + }} +} + // stringBuilder is the builder for string fields. type stringBuilder struct { desc *Descriptor @@ -438,7 +455,67 @@ func (b *jsonsBuilder) Comment(c string) *jsonsBuilder { return b } +// StructTag sets the struct tag of the field. +func (b *jsonsBuilder) StructTag(s string) *jsonsBuilder { + b.desc.Tag = s + return b +} + // Descriptor implements the ent.Field interface by returning its descriptor. func (b *jsonsBuilder) Descriptor() *Descriptor { return b.desc } + +// enumBuilder is the builder for enum fields. +type enumBuilder struct { + desc *Descriptor +} + +// Value sets the numeric value of the enum. Defaults to its index in the declaration. +func (b *enumBuilder) Values(values ...string) *enumBuilder { + b.desc.Enums = values + return b +} + +// StorageKey sets the storage key of the field. +// In SQL dialects is the column name and Gremlin is the property. +func (b *enumBuilder) StorageKey(key string) *enumBuilder { + b.desc.StorageKey = key + return b +} + +// Optional indicates that this field is optional on create. +// Unlike edges, fields are required by default. +func (b *enumBuilder) Optional() *enumBuilder { + b.desc.Optional = true + return b +} + +// Immutable indicates that this field cannot be updated. +func (b *enumBuilder) Immutable() *enumBuilder { + b.desc.Immutable = true + return b +} + +// Comment sets the comment of the field. +func (b *enumBuilder) Comment(c string) *enumBuilder { + return b +} + +// Nillable indicates that this field is a nillable. +// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated field. +func (b *enumBuilder) Nillable() *enumBuilder { + b.desc.Nillable = true + return b +} + +// StructTag sets the struct tag of the field. +func (b *enumBuilder) StructTag(s string) *enumBuilder { + b.desc.Tag = s + return b +} + +// Descriptor implements the ent.Field interface by returning its descriptor. +func (b *enumBuilder) Descriptor() *Descriptor { + return b.desc +} diff --git a/schema/field/field_test.go b/schema/field/field_test.go index 22345dde7..7e01f092a 100644 --- a/schema/field/field_test.go +++ b/schema/field/field_test.go @@ -141,3 +141,15 @@ func TestField_Tag(t *testing.T) { Descriptor() assert.Equal(t, `json:"expired,omitempty"`, fd.Tag) } + +func TestField_Enums(t *testing.T) { + fd := field.Enum("role"). + Values( + "user", + "admin", + "master", + ). + Descriptor() + require.Equal(t, "role", fd.Name) + require.Equal(t, []string{"user", "admin", "master"}, fd.Enums) +} diff --git a/schema/field/gen/numeric.tmpl b/schema/field/gen/numeric.tmpl index 75676fcc7..f55f3a830 100644 --- a/schema/field/gen/numeric.tmpl +++ b/schema/field/gen/numeric.tmpl @@ -263,4 +263,4 @@ func (b *{{ $builder }}) Descriptor() *Descriptor { } {{ end }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/schema/field/type.go b/schema/field/type.go index c1c488033..70f253756 100644 --- a/schema/field/type.go +++ b/schema/field/type.go @@ -10,6 +10,7 @@ const ( TypeTime TypeJSON TypeBytes + TypeEnum TypeString TypeInt8 TypeInt16 @@ -39,16 +40,19 @@ func (t Type) Numeric() bool { return t >= TypeInt8 && t < endTypes } +// Valid reports if the given type if known type. +func (t Type) Valid() bool { + return t > TypeInvalid && t < endTypes +} + // ConstName returns the constant name of a info type. // It's used by entc for printing the constant name in templates. func (t Type) ConstName() string { - switch t { - case TypeJSON: - return "TypeJSON" - case TypeTime: - return "TypeTime" - case TypeBytes: - return "TypeBytes" + switch { + case !t.Valid(): + return typeNames[TypeInvalid] + case int(t) < len(constNames) && constNames[t] != "": + return constNames[t] default: return "Type" + strings.Title(typeNames[t]) } @@ -75,7 +79,7 @@ func (t TypeInfo) String() string { // Valid reports if the given type if known type. func (t TypeInfo) Valid() bool { - return t.Type > TypeInvalid && t.Type < endTypes + return t.Type.Valid() } // Numeric reports if the given type is a numeric type. @@ -83,23 +87,32 @@ func (t TypeInfo) Numeric() bool { return t.Type.Numeric() } -var typeNames = [...]string{ - TypeInvalid: "invalid", - TypeBool: "bool", - TypeTime: "time.Time", - TypeJSON: "json.RawMessage", - TypeBytes: "[]byte", - TypeString: "string", - TypeInt: "int", - TypeInt8: "int8", - TypeInt16: "int16", - TypeInt32: "int32", - TypeInt64: "int64", - TypeUint: "uint", - TypeUint8: "uint8", - TypeUint16: "uint16", - TypeUint32: "uint32", - TypeUint64: "uint64", - TypeFloat32: "float32", - TypeFloat64: "float64", -} +var ( + typeNames = [...]string{ + TypeInvalid: "invalid", + TypeBool: "bool", + TypeTime: "time.Time", + TypeJSON: "json.RawMessage", + TypeBytes: "[]byte", + TypeEnum: "string", + TypeString: "string", + TypeInt: "int", + TypeInt8: "int8", + TypeInt16: "int16", + TypeInt32: "int32", + TypeInt64: "int64", + TypeUint: "uint", + TypeUint8: "uint8", + TypeUint16: "uint16", + TypeUint32: "uint32", + TypeUint64: "uint64", + TypeFloat32: "float32", + TypeFloat64: "float64", + } + constNames = [...]string{ + TypeJSON: "TypeJSON", + TypeTime: "TypeTime", + TypeEnum: "TypeEnum", + TypeBytes: "TypeBytes", + } +)