From b71ee6820b7e1b301e0b6ad7d2888c792d9ba5d7 Mon Sep 17 00:00:00 2001 From: Alex Snast Date: Thu, 29 Aug 2019 07:33:41 -0700 Subject: [PATCH] ent/schema: remove string field charset / collation settings Summary: don't expose starage specific features in ent schema Reviewed By: a8m Differential Revision: D17111724 fbshipit-source-id: fca9e624b272c0db3fed14c511fa6cb07816a100 --- dialect/sql/schema/migrate.go | 3 - dialect/sql/schema/mysql_test.go | 8 +- dialect/sql/schema/schema.go | 14 +- entc/gen/bindata.go | 95 +++++---- entc/gen/template/migrate/schema.tmpl | 4 +- entc/gen/type.go | 6 - entc/integration/ent/example_test.go | 4 - entc/integration/ent/file.go | 10 - entc/integration/ent/file/file.go | 3 - entc/integration/ent/file/where.go | 188 ------------------ entc/integration/ent/file_create.go | 42 +--- entc/integration/ent/file_update.go | 81 -------- entc/integration/ent/migrate/schema.go | 11 +- entc/integration/ent/schema/file.go | 4 - entc/integration/integration_test.go | 33 +-- .../integration/migrate/entv1/example_test.go | 1 - .../migrate/entv1/migrate/schema.go | 1 - entc/integration/migrate/entv1/schema/user.go | 1 - entc/integration/migrate/entv1/user.go | 6 - entc/integration/migrate/entv1/user/user.go | 3 - entc/integration/migrate/entv1/user/where.go | 164 --------------- entc/integration/migrate/entv1/user_create.go | 19 -- entc/integration/migrate/entv1/user_update.go | 39 ---- .../integration/migrate/entv2/example_test.go | 1 - .../migrate/entv2/migrate/schema.go | 1 - entc/integration/migrate/entv2/schema/user.go | 4 - entc/integration/migrate/entv2/user.go | 6 - entc/integration/migrate/entv2/user/user.go | 3 - entc/integration/migrate/entv2/user/where.go | 164 --------------- entc/integration/migrate/entv2/user_create.go | 19 -- entc/integration/migrate/entv2/user_update.go | 39 ---- entc/integration/migrate/migrate_test.go | 25 +-- entc/load/bindata.go | 21 +- entc/load/schema.go | 8 - schema/field/field.go | 16 -- schema/field/field_test.go | 14 -- 36 files changed, 84 insertions(+), 977 deletions(-) diff --git a/dialect/sql/schema/migrate.go b/dialect/sql/schema/migrate.go index 2e71ac6d7..5ffe3a2e2 100644 --- a/dialect/sql/schema/migrate.go +++ b/dialect/sql/schema/migrate.go @@ -279,9 +279,6 @@ func (m *Migrate) changeSet(curr, new *Table) (*changes, error) { fallthrough // change nullability of a column. case c1.Nullable != c2.Nullable: - fallthrough - // modify character encoding. - case c1.Charset != "" && c1.Charset != c2.Charset || c1.Collation != "" && c1.Collation != c2.Collation: change.column.modify = append(change.column.modify, c1) } } diff --git a/dialect/sql/schema/mysql_test.go b/dialect/sql/schema/mysql_test.go index 2bf47848b..532690db9 100644 --- a/dialect/sql/schema/mysql_test.go +++ b/dialect/sql/schema/mysql_test.go @@ -51,7 +51,7 @@ func TestMySQL_Create(t *testing.T) { }, Columns: []*Column{ {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "name", Type: field.TypeString, Nullable: true, Charset: "utf8"}, + {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "age", Type: field.TypeInt}, }, }, @@ -63,7 +63,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) CHARACTER SET utf8 NULL, `age` bigint NOT 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, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4")). WillReturnResult(sqlmock.NewResult(0, 1)) mock.ExpectCommit() }, @@ -412,7 +412,7 @@ func TestMySQL_Create(t *testing.T) { Columns: []*Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "age", Type: field.TypeInt}, - {Name: "name", Type: field.TypeString, Nullable: true, Charset: "utf8", Collation: "utf8_general_ci"}, + {Name: "name", Type: field.TypeString, Nullable: true}, }, PrimaryKey: []*Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -436,7 +436,7 @@ func TestMySQL_Create(t *testing.T) { 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 `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL")). + mock.ExpectExec(escape("ALTER TABLE `users` MODIFY COLUMN `name` varchar(255) NULL")). WillReturnResult(sqlmock.NewResult(0, 1)) mock.ExpectCommit() }, diff --git a/dialect/sql/schema/schema.go b/dialect/sql/schema/schema.go index d5ee3a6fb..798f0a537 100644 --- a/dialect/sql/schema/schema.go +++ b/dialect/sql/schema/schema.go @@ -180,8 +180,6 @@ type Column struct { Increment bool // auto increment attribute. Nullable bool // null or not null attribute. Default interface{} // default value. - Charset string // column character set. - Collation string // column collation. indexes Indexes // linked indexes. } @@ -197,16 +195,10 @@ func (c *Column) PrimaryKey() bool { return c.Key == PrimaryKey } // The syntax/order is: datatype [Charset] [Unique|Increment] [Collation] [Nullable]. func (c *Column) MySQL(version string) *sql.ColumnBuilder { b := sql.Column(c.Name).Type(c.MySQLType(version)).Attr(c.Attr) - if c.Charset != "" { - b.Attr("CHARACTER SET " + c.Charset) - } c.unique(b) if c.Increment { b.Attr("AUTO_INCREMENT") } - if c.Collation != "" { - b.Attr("COLLATE " + c.Collation) - } c.nullable(b) c.defaultValue(b) return b @@ -301,17 +293,13 @@ func (c *Column) SQLiteType() (t string) { // ScanMySQL scans the information from MySQL column description. func (c *Column) ScanMySQL(rows *sql.Rows) error { var ( - charset sql.NullString - collate sql.NullString nullable sql.NullString defaults sql.NullString ) - if err := rows.Scan(&c.Name, &c.typ, &nullable, &c.Key, &defaults, &c.Attr, &charset, &collate); err != nil { + if err := rows.Scan(&c.Name, &c.typ, &nullable, &c.Key, &defaults, &c.Attr, &sql.NullString{}, &sql.NullString{}); err != nil { return fmt.Errorf("scanning column description: %v", err) } c.Unique = c.UniqueKey() - c.Charset = charset.String - c.Collation = collate.String if nullable.Valid { c.Nullable = nullable.String == "YES" } diff --git a/entc/gen/bindata.go b/entc/gen/bindata.go index d2864f1de..dc81afd05 100644 --- a/entc/gen/bindata.go +++ b/entc/gen/bindata.go @@ -1,4 +1,4 @@ -// Code generated by go-bindata. (@generated) DO NOT EDIT. +// Package gen Code generated by go-bindata. (@generated) DO NOT EDIT. // sources: // template/base.tmpl // template/builder/create.tmpl @@ -85,21 +85,32 @@ type bindataFileInfo struct { modTime time.Time } +// Name return file name func (fi bindataFileInfo) Name() string { return fi.name } + +// Size return file size func (fi bindataFileInfo) Size() int64 { return fi.size } + +// Mode return file mode func (fi bindataFileInfo) Mode() os.FileMode { return fi.mode } + +// Mode return file modify time func (fi bindataFileInfo) ModTime() time.Time { return fi.modTime } + +// IsDir return file whether a directory func (fi bindataFileInfo) IsDir() bool { - return false + return fi.mode&os.ModeDir != 0 } + +// Sys return file is sys mode func (fi bindataFileInfo) Sys() interface{} { return nil } @@ -119,7 +130,7 @@ func templateBaseTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/base.tmpl", size: 5021, mode: os.FileMode(420), modTime: time.Unix(1564913315, 0)} + info := bindataFileInfo{name: "template/base.tmpl", size: 5021, mode: os.FileMode(420), modTime: time.Unix(1565007749, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -139,7 +150,7 @@ func templateBuilderCreateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/create.tmpl", size: 2845, mode: os.FileMode(420), modTime: time.Unix(1566979817, 0)} + info := bindataFileInfo{name: "template/builder/create.tmpl", size: 2845, mode: os.FileMode(420), modTime: time.Unix(1566925536, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -159,7 +170,7 @@ func templateBuilderDeleteTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/delete.tmpl", size: 2044, mode: os.FileMode(420), modTime: time.Unix(1565106398, 0)} + info := bindataFileInfo{name: "template/builder/delete.tmpl", size: 2044, mode: os.FileMode(420), modTime: time.Unix(1565162769, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -179,7 +190,7 @@ func templateBuilderQueryTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/query.tmpl", size: 13220, mode: os.FileMode(420), modTime: time.Unix(1565165343, 0)} + info := bindataFileInfo{name: "template/builder/query.tmpl", size: 13220, mode: os.FileMode(420), modTime: time.Unix(1565178244, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -199,7 +210,7 @@ func templateBuilderSetterTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/setter.tmpl", size: 3256, mode: os.FileMode(420), modTime: time.Unix(1566979817, 0)} + info := bindataFileInfo{name: "template/builder/setter.tmpl", size: 3256, mode: os.FileMode(420), modTime: time.Unix(1566925536, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -219,7 +230,7 @@ func templateBuilderUpdateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/update.tmpl", size: 7651, mode: os.FileMode(420), modTime: time.Unix(1566979817, 0)} + info := bindataFileInfo{name: "template/builder/update.tmpl", size: 7651, mode: os.FileMode(420), modTime: time.Unix(1566925536, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -239,7 +250,7 @@ func templateClientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/client.tmpl", size: 4844, mode: os.FileMode(420), modTime: time.Unix(1567007034, 0)} + info := bindataFileInfo{name: "template/client.tmpl", size: 4844, mode: os.FileMode(420), modTime: time.Unix(1567076802, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -259,7 +270,7 @@ func templateConfigTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/config.tmpl", size: 1058, mode: os.FileMode(420), modTime: time.Unix(1567007034, 0)} + info := bindataFileInfo{name: "template/config.tmpl", size: 1058, mode: os.FileMode(420), modTime: time.Unix(1567000965, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -279,7 +290,7 @@ func templateContextTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/context.tmpl", size: 523, mode: os.FileMode(420), modTime: time.Unix(1564913326, 0)} + info := bindataFileInfo{name: "template/context.tmpl", size: 523, mode: os.FileMode(420), modTime: time.Unix(1565007749, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -299,7 +310,7 @@ func templateDialectGremlinByTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/by.tmpl", size: 1679, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/by.tmpl", size: 1679, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -319,7 +330,7 @@ func templateDialectGremlinCreateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/create.tmpl", size: 2567, mode: os.FileMode(420), modTime: time.Unix(1558503319, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/create.tmpl", size: 2567, mode: os.FileMode(420), modTime: time.Unix(1560858191, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -339,7 +350,7 @@ func templateDialectGremlinDecodeTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/decode.tmpl", size: 1924, mode: os.FileMode(420), modTime: time.Unix(1566981175, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/decode.tmpl", size: 1924, mode: os.FileMode(420), modTime: time.Unix(1566987566, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -359,7 +370,7 @@ func templateDialectGremlinDeleteTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/delete.tmpl", size: 541, mode: os.FileMode(420), modTime: time.Unix(1563979564, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/delete.tmpl", size: 541, mode: os.FileMode(420), modTime: time.Unix(1564440681, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -379,7 +390,7 @@ func templateDialectGremlinErrorsTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/errors.tmpl", size: 1608, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/errors.tmpl", size: 1608, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -399,7 +410,7 @@ func templateDialectGremlinGroupTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/group.tmpl", size: 1151, mode: os.FileMode(420), modTime: time.Unix(1558503319, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/group.tmpl", size: 1151, mode: os.FileMode(420), modTime: time.Unix(1560858192, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -419,7 +430,7 @@ func templateDialectGremlinMetaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/meta.tmpl", size: 508, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/meta.tmpl", size: 508, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -439,7 +450,7 @@ func templateDialectGremlinPredicateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/predicate.tmpl", size: 3117, mode: os.FileMode(420), modTime: time.Unix(1565183614, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/predicate.tmpl", size: 3117, mode: os.FileMode(420), modTime: time.Unix(1565187546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -459,7 +470,7 @@ func templateDialectGremlinQueryTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/query.tmpl", size: 3733, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/query.tmpl", size: 3733, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -479,7 +490,7 @@ func templateDialectGremlinUpdateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/gremlin/update.tmpl", size: 4840, mode: os.FileMode(420), modTime: time.Unix(1566979817, 0)} + info := bindataFileInfo{name: "template/dialect/gremlin/update.tmpl", size: 4840, mode: os.FileMode(420), modTime: time.Unix(1566925536, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -499,7 +510,7 @@ func templateDialectSqlByTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/by.tmpl", size: 753, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/sql/by.tmpl", size: 753, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -519,7 +530,7 @@ func templateDialectSqlCreateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/create.tmpl", size: 6066, mode: os.FileMode(420), modTime: time.Unix(1565180278, 0)} + info := bindataFileInfo{name: "template/dialect/sql/create.tmpl", size: 6066, mode: os.FileMode(420), modTime: time.Unix(1565187546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -539,7 +550,7 @@ func templateDialectSqlDecodeTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/decode.tmpl", size: 1820, mode: os.FileMode(420), modTime: time.Unix(1566224080, 0)} + info := bindataFileInfo{name: "template/dialect/sql/decode.tmpl", size: 1820, mode: os.FileMode(420), modTime: time.Unix(1566217695, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -559,7 +570,7 @@ func templateDialectSqlDeleteTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/delete.tmpl", size: 489, mode: os.FileMode(420), modTime: time.Unix(1563979564, 0)} + info := bindataFileInfo{name: "template/dialect/sql/delete.tmpl", size: 489, mode: os.FileMode(420), modTime: time.Unix(1564440681, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -579,7 +590,7 @@ func templateDialectSqlErrorsTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/errors.tmpl", size: 771, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/sql/errors.tmpl", size: 771, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -599,7 +610,7 @@ func templateDialectSqlGroupTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/group.tmpl", size: 835, mode: os.FileMode(420), modTime: time.Unix(1558503319, 0)} + info := bindataFileInfo{name: "template/dialect/sql/group.tmpl", size: 835, mode: os.FileMode(420), modTime: time.Unix(1560858192, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -619,7 +630,7 @@ func templateDialectSqlMetaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/meta.tmpl", size: 1586, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/sql/meta.tmpl", size: 1586, mode: os.FileMode(420), modTime: time.Unix(1564494654, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -639,7 +650,7 @@ func templateDialectSqlPredicateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 4330, mode: os.FileMode(420), modTime: time.Unix(1565183595, 0)} + info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 4330, mode: os.FileMode(420), modTime: time.Unix(1565187546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -659,7 +670,7 @@ func templateDialectSqlQueryTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/query.tmpl", size: 6186, mode: os.FileMode(420), modTime: time.Unix(1564480239, 0)} + info := bindataFileInfo{name: "template/dialect/sql/query.tmpl", size: 6186, mode: os.FileMode(420), modTime: time.Unix(1564498182, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -679,7 +690,7 @@ func templateDialectSqlUpdateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/update.tmpl", size: 11432, mode: os.FileMode(420), modTime: time.Unix(1566979817, 0)} + info := bindataFileInfo{name: "template/dialect/sql/update.tmpl", size: 11432, mode: os.FileMode(420), modTime: time.Unix(1566925536, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -699,7 +710,7 @@ func templateEntTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/ent.tmpl", size: 3369, mode: os.FileMode(420), modTime: time.Unix(1565180140, 0)} + info := bindataFileInfo{name: "template/ent.tmpl", size: 3369, mode: os.FileMode(420), modTime: time.Unix(1565187546, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -719,7 +730,7 @@ func templateExampleTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/example.tmpl", size: 2229, mode: os.FileMode(420), modTime: time.Unix(1566224088, 0)} + info := bindataFileInfo{name: "template/example.tmpl", size: 2229, mode: os.FileMode(420), modTime: time.Unix(1566238093, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -739,7 +750,7 @@ func templateHeaderTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/header.tmpl", size: 240, mode: os.FileMode(420), modTime: time.Unix(1564913919, 0)} + info := bindataFileInfo{name: "template/header.tmpl", size: 240, mode: os.FileMode(420), modTime: time.Unix(1565007749, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -759,7 +770,7 @@ func templateImportTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/import.tmpl", size: 556, mode: os.FileMode(420), modTime: time.Unix(1566224088, 0)} + info := bindataFileInfo{name: "template/import.tmpl", size: 556, mode: os.FileMode(420), modTime: time.Unix(1566238093, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -779,7 +790,7 @@ func templateMetaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/meta.tmpl", size: 2628, mode: os.FileMode(420), modTime: time.Unix(1566979817, 0)} + info := bindataFileInfo{name: "template/meta.tmpl", size: 2628, mode: os.FileMode(420), modTime: time.Unix(1566925536, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -799,12 +810,12 @@ func templateMigrateMigrateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/migrate/migrate.tmpl", size: 1738, mode: os.FileMode(420), modTime: time.Unix(1566224088, 0)} + info := bindataFileInfo{name: "template/migrate/migrate.tmpl", size: 1738, mode: os.FileMode(420), modTime: time.Unix(1566238093, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _templateMigrateSchemaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x57\x4d\x8f\xdb\x36\x10\x3d\x4b\xbf\x62\x20\xa8\x45\xb2\xf0\x4a\x4d\x8e\x06\x7c\x28\x36\x28\x1a\x04\xd8\x06\x4d\x72\x0a\x82\x82\x2b\x8d\x2c\xc2\x12\xa9\x95\xe8\x74\x5d\x56\xff\xbd\xe0\xa7\x68\x59\xf6\x3a\x4d\xf6\x62\x91\x9c\x79\xe4\xbc\x79\xc3\xe1\x4a\x09\x25\x56\x94\x21\x24\x43\x51\x63\x4b\x12\x18\xc7\x38\x96\xf2\x16\xfe\xa6\xa2\x06\x7c\x12\xc8\x4a\x48\x21\x79\x4f\x8a\x1d\xd9\x62\x02\x49\x4b\xb7\x3d\x11\x98\xc0\xed\x38\xc6\x91\x94\x20\xb0\xed\x1a\x22\x10\x92\x1a\x49\x89\x7d\x02\x99\x42\x91\x12\x94\xaf\xc2\xa3\x6d\xc7\x7b\x01\x2f\xb4\x79\x4f\xd8\x16\x21\xfd\x6b\x05\x29\x83\xf5\x06\xd2\xec\x9e\x97\x38\x28\xc3\x28\x4a\xa4\x84\x34\xbb\xe3\xac\xa2\xdb\xcc\xee\x09\xe3\x98\xeb\xe9\x69\x9c\x68\x24\x07\x1f\x25\x5b\x2a\xea\xfd\x43\x56\xf0\x36\xaf\x48\x81\x0f\x9c\xef\x28\x2b\xf6\x0f\x44\xf0\x3e\x47\x26\x72\x13\x5d\x5e\x51\x6c\xca\xe4\x1a\x87\x92\x92\x06\x0b\x91\x0f\x8f\x8d\x75\x4e\xe2\x97\x71\xfc\x95\xf4\x26\x8c\xdb\x30\x0e\x61\xe2\xf8\x48\x1e\x1a\x17\x88\xb2\xc8\x6f\xa0\xa2\xac\x04\x71\xe8\x10\x18\x2f\x11\x28\x03\x51\x23\x6c\x7b\xd2\xd5\xc0\x2b\x10\x35\x1d\x40\x28\xb7\x15\xd0\x0a\xf0\x89\x0e\x62\x80\x9b\xdc\x43\xa4\xda\x6d\xbd\x01\xca\x4a\x7c\xf2\x5c\xfd\x32\x6d\x72\x9e\x4e\x29\x35\xe6\x23\xa4\x22\xbb\x27\x2d\x42\xca\xcc\x11\xcd\x9a\x81\xde\x28\x37\x3d\x36\x6c\x4e\xb4\xda\x03\x14\xbc\xd9\xb7\x6c\x50\xd0\x1d\x19\x0a\xd2\x78\xb8\x7f\xa1\xeb\x29\x13\x15\x24\x3f\x0d\x77\xc6\x2a\x31\x8e\x79\x0e\x6a\x03\xe7\x3a\x8e\x50\xf3\xa6\x1c\x74\xec\x6e\xb2\xe2\xbd\x1e\xeb\x8c\x5b\xc4\x71\x4c\x0c\x1b\x99\xde\xfd\x08\x61\x03\x9f\xbf\xdc\x98\x4c\x64\x66\x37\x19\x47\x27\x14\x14\x9a\x02\x61\x2d\x6c\x2e\xa2\x48\x82\xc2\x5f\x9b\xcd\x0a\xbf\xd9\x0a\x3e\x1e\x3a\x5c\x83\x96\x45\x66\xd6\xd4\x8c\x12\xe0\x20\xac\xd5\xca\x20\xc8\x5b\xc5\x66\x5a\x64\x9f\x18\x7d\xdc\xab\x05\x30\x5f\x6b\x10\xfd\x1e\x57\x21\x71\xa1\xf9\x5b\x56\xf4\xd8\x22\x13\xca\xc3\x0f\x9e\x71\xba\xdf\x37\x8d\xcd\x14\xb8\xef\x35\xd8\xc3\x4f\x6b\x0b\xfe\xba\x6c\xd3\x22\xfb\x40\xff\xd1\xde\xea\x57\x7b\x66\x97\xed\x7f\x15\xa2\x57\xf6\xea\xd7\xf0\x94\x69\x86\xce\x9d\xf0\x77\x32\xbc\xc1\x8a\xec\x1b\x1d\x97\xfd\x34\x47\x54\xba\x0a\x6a\x35\xb3\x8b\x52\x7a\x01\xf9\x0c\x5c\x38\xd0\x5d\x4d\xfa\x01\x35\xba\xfd\xbc\x7c\x2c\xef\xc7\x9b\x86\x08\xca\x99\xf6\x74\x83\x45\x5f\x93\x5a\xe5\xec\xb1\xbc\xec\xb5\x0c\x9f\x11\xbd\x2e\xa6\x63\xc9\x0b\x97\xb5\x49\xf0\x46\xb3\x40\x59\xc5\xfb\xd6\x9c\xec\x2a\xed\x7b\xa8\x0d\xfc\x6c\x75\xaf\x37\xd4\xb2\x0f\xe4\x3c\xf9\xeb\x70\xac\xf2\xd7\xb3\x0a\xd4\x6b\xef\x7b\xda\x92\xfe\xf0\x0e\x0f\xeb\xe5\x6a\x9a\x97\x53\xb7\xb3\xf5\x34\x79\x3a\xce\x43\x53\x7a\xbe\xf2\xbc\x66\xd4\x3d\xd4\xed\xec\x45\xe4\x05\x70\x7c\xc8\xcf\x6a\x48\x61\x1c\xbf\xcc\x12\x7c\x9c\xa4\xf9\xd0\x04\xf7\x1b\xef\x91\x6e\xd9\x3b\x3c\x0c\x61\x74\xd3\xf4\x62\x84\x95\x8b\x30\x70\x9f\x76\xb5\x21\x7c\x38\xb4\x0f\xbc\xb1\x7c\x57\xbb\xcc\x8c\x3d\xe5\x21\xeb\xcb\xb4\x46\x00\xa7\x57\xd5\x2b\xbd\x73\xb5\x3b\xa5\xec\x94\xdc\xd7\xe7\xd8\x3d\x26\xb8\x78\xe5\x08\x7e\xfd\xad\x0c\x9f\x92\xbc\x34\x33\xae\x7c\x56\xf3\x1b\xe8\xf8\x20\x3a\xce\x10\x7a\xac\x7a\x64\x05\x65\x5b\x10\x1c\xc8\x57\x4e\x4d\xd7\x2b\x6a\x2c\x76\x6a\xb6\xe1\xbc\xf3\x8d\x4d\xfd\xfd\x89\xd5\x77\x71\x36\xf9\x3f\x4f\x9b\x31\xd7\xc5\xf3\xff\x08\x74\x77\x40\x08\x74\xa9\x05\xfe\x40\x96\xdd\xc5\x56\xed\xb2\x3f\xd8\xa7\xae\x24\xe2\xb8\x3b\x39\x0c\xb7\xb8\xb6\xf7\x4d\xe6\xae\xfc\xf8\xcc\x1e\x33\xe8\x37\xd8\xe0\x59\x68\xb3\x78\x2d\x74\xd0\x31\xe7\x35\xea\xfa\x87\xc8\xde\xaa\xf7\x0c\xfa\x3c\xd8\x61\xa8\x05\x3d\x25\x4f\xee\x1a\x25\x03\x5a\x3e\xd9\x7a\x98\xc1\x4c\x25\x1b\xde\x90\xb4\x7c\x3a\xbe\x23\xd5\x9f\x6b\xde\xce\xc0\xb7\x75\x6f\xf1\x9c\x3e\x17\x5e\x1f\x46\x9e\x0a\xee\x9c\xce\xae\x2d\xea\x1f\x57\xd5\x0b\x82\x5b\x98\xf2\x61\xbb\x8f\x99\xc9\x72\xaf\x0c\xc7\x79\x0e\xf6\x01\x6c\x7a\x1f\x69\x1a\xdd\xe4\x84\x99\xb4\x4f\x5f\x4b\x64\x1c\x59\xdb\xf0\x59\xe7\xdb\xdb\xf3\xcf\xeb\x28\xa8\xca\x4b\x9d\x79\x15\x1f\x1f\x7a\x54\x8f\xf8\x6a\xcf\x0a\xa0\x8c\x8a\x17\x2f\x41\x5e\xfb\x98\xff\xe6\x17\xc1\x2c\xdb\x17\x1a\x4d\xd8\xed\xc3\xe5\x29\xad\xfe\xda\x81\x0d\x5c\x7b\x1f\xcd\xcf\xe2\x28\x08\xbe\xf5\xbf\x7a\x76\xf0\x5f\x00\x00\x00\xff\xff\x51\x86\xdf\xe4\x0b\x0e\x00\x00") +var _templateMigrateSchemaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x57\x4d\x8f\xdb\x36\x10\x3d\x4b\xbf\x62\x20\xa8\x45\xb2\xf0\x4a\x4d\x8e\x06\x7c\x28\x12\x14\x0d\x02\x6c\x83\x26\x39\x05\x41\x41\x4b\x23\x9b\xb0\x44\x6a\x25\x3a\xb5\xcb\xea\xbf\x17\xfc\x14\x2d\xcb\x6b\xa7\xd9\xbd\x58\x24\x67\x1e\x39\x6f\x1e\x67\xb8\x52\x42\x89\x15\x65\x08\x49\x5f\x6c\xb1\x21\x09\x0c\x43\x1c\x4b\x79\x0f\x7f\x53\xb1\x05\x3c\x08\x64\x25\xa4\x90\x7c\x20\xc5\x8e\x6c\x30\x81\xa4\xa1\x9b\x8e\x08\x4c\xe0\x7e\x18\xe2\x48\x4a\x10\xd8\xb4\x35\x11\x08\xc9\x16\x49\x89\x5d\x02\x99\x42\x91\x12\x94\xaf\xc2\xa3\x4d\xcb\x3b\x01\x2f\xb4\x79\x47\xd8\x06\x21\xfd\x6b\x01\x29\x83\xe5\x0a\xd2\xec\x81\x97\xd8\x2b\xc3\x28\x4a\xa4\x84\x34\x7b\xc3\x59\x45\x37\x99\xdd\x13\x86\x21\xd7\xd3\xe3\x38\xd1\x48\x0e\x3e\x4a\x36\x54\x6c\xf7\xeb\xac\xe0\x4d\x5e\x91\x02\xd7\x9c\xef\x28\x2b\xf6\x6b\x22\x78\x97\x23\x13\xb9\x89\x2e\xaf\x28\xd6\x65\x72\x8b\x43\x49\x49\x8d\x85\xc8\xfb\xc7\xda\x3a\x27\xf1\xcb\x38\xfe\x46\x3a\x13\xc6\x7d\x18\x87\x30\x71\x7c\x22\xeb\xda\x05\xa2\x2c\xf2\x3b\xa8\x28\x2b\x41\x1c\x5b\x04\xc6\x4b\x04\xca\x40\x6c\x11\x36\x1d\x69\xb7\xc0\x2b\x10\x5b\xda\x83\x50\x6e\x0b\xa0\x15\xe0\x81\xf6\xa2\x87\xbb\xdc\x43\xa4\xda\x6d\xb9\x02\xca\x4a\x3c\x78\xae\x7e\x19\x37\xb9\x4c\xa7\x94\x1a\xf3\x11\x52\x91\x3d\x90\x06\x21\x65\xe6\x88\x66\xcd\x40\xaf\x94\x9b\x1e\x1b\x36\x47\x5a\xed\x01\x0a\x5e\xef\x1b\xd6\x2b\xe8\x96\xf4\x05\xa9\x3d\xdc\xbf\xd0\x76\x94\x89\x0a\x92\x9f\xfa\x37\xc6\x2a\x31\x8e\x79\x0e\x6a\x03\xe7\x3a\x0c\xb0\xe5\x75\xd9\xeb\xd8\xdd\x64\xc5\x3b\x3d\xd6\x19\xb7\x88\xc3\x90\x18\x36\x32\xbd\xfb\x09\xc2\x0a\xbe\x7c\xbd\x33\x99\xc8\xcc\x6e\x32\x8e\xce\x28\x28\x34\x05\xc2\x5a\xd8\x5c\x44\x91\x04\x85\xbf\x34\x9b\x15\x7e\xb3\x05\x7c\x3a\xb6\xb8\x04\x2d\x8b\xcc\xac\xa9\x19\x25\xc0\x5e\x58\xab\x85\x41\x90\xf7\x8a\xcd\xb4\xc8\x3e\x33\xfa\xb8\x57\x0b\x60\xbe\x96\x20\xba\x3d\x2e\x42\xe2\x42\xf3\x77\xac\xe8\xb0\x41\x26\x94\x87\x1f\x5c\x71\x7a\xd8\xd7\xb5\xcd\x14\xb8\xef\x25\xd8\xc3\x8f\x6b\x33\xfe\xfa\xda\xa6\x45\xf6\x91\xfe\xa3\xbd\xd5\xaf\xf6\xcc\x9e\xb6\xff\x55\x88\x4e\xd9\xab\x5f\xc3\x53\xa6\x19\xba\x74\xc2\xdf\x49\xff\x16\x2b\xb2\xaf\x75\x5c\xf6\xd3\x1c\x51\xe9\x2a\xb8\xab\x99\x5d\x94\xd2\x0b\xc8\x67\x60\x84\x37\x34\x2b\x7c\xbf\x9d\x97\xa0\x96\xc4\x15\x01\x6a\x61\x9f\xca\x4f\x38\x06\x47\xf1\x19\xfd\x00\x65\x15\xef\x1a\x22\x28\x67\xb7\xe9\xd0\x43\xad\xe0\x67\xab\x41\xbd\xa1\x96\x60\x20\xad\xd1\x5f\x87\x63\x55\xb8\x9c\xdc\x06\xbd\xf6\xa1\xa3\x0d\xe9\x8e\xef\xf1\xb8\x9c\x57\xf6\x54\xda\xed\xce\x6a\x7b\xf4\x74\x69\x09\x4d\xe9\xe5\x5b\xe0\xf3\xa7\x6a\x42\xbb\xb3\x45\xc1\x27\xe3\xf4\x90\x5f\xd4\x90\xc2\x30\x7c\x9d\x68\xe0\x34\x49\xd3\xa1\x09\xee\x37\xde\x21\xdd\xb0\xf7\x78\xec\xc3\xe8\xc6\xe9\xd9\x08\x2b\x17\x61\xe0\x3e\xee\x6a\x43\xf8\x78\x6c\xd6\xbc\xb6\x7c\x57\xbb\xcc\x8c\x3d\xe5\x21\xeb\xf3\xb4\x46\x00\xe7\x65\xe3\x95\xde\xb9\xda\x9d\x53\x76\x4e\xee\xeb\x4b\xec\x9e\x12\x5c\xbc\x72\x04\xbf\xfe\x5e\x86\xcf\x49\x9e\x9b\x19\x16\x3e\xab\xf9\x1d\xb4\xbc\x17\x2d\x67\x08\x1d\x56\x1d\xb2\x82\xb2\x0d\x08\x0e\xe4\x1b\xa7\xa6\x03\x15\x5b\x2c\x76\x6a\xb6\xe6\xbc\xf5\x4d\x46\xfd\xfd\x89\xd5\x0f\x71\x36\xfa\x5f\xa7\xcd\x98\xeb\xcb\xf3\xff\x08\x74\x35\x20\x04\x7a\xaa\x1d\x3d\x23\xcb\xae\x5a\x56\xbb\xec\x0f\xf6\xb9\x2d\x89\x38\xed\x14\x0e\xc3\x2d\x2e\x6d\xbd\xc9\x5c\xf9\x8d\x2f\xec\x31\x81\x7e\x8b\x35\x5e\x84\x36\x8b\xb7\x42\x07\xdd\x6b\x7a\x47\x5d\x2d\x17\xd9\x3b\xf5\xb6\x40\x9f\x07\x3b\x0c\xb5\xa0\xa7\xe4\x59\xad\x51\x32\xa0\xe5\xc1\xde\x87\x09\xcc\x78\x65\xc3\x0a\x49\xcb\xc3\x69\x8d\x54\x7f\xae\x91\x3a\x03\xdf\x62\xbd\xc5\x35\x7d\xce\xbc\x04\x8c\x3c\x15\xdc\x25\x9d\xdd\x7a\xa9\x9f\xef\x56\xcf\x08\x6e\x66\xca\x87\xed\x3e\x26\x26\xf3\xbd\x32\x1c\xe7\x39\xd8\xc7\xa8\xe9\x7d\xa4\xae\x75\x93\x13\x66\xd2\x3e\x43\x2d\x91\x71\x64\x6d\xc3\x27\x96\x6f\x6f\xd7\x9f\xba\x51\x70\x2b\x9f\xea\xcc\x8b\xf8\xf4\xd0\x83\x7a\x50\x57\x7b\x56\x00\x65\x54\xbc\x78\x09\xf2\xd6\x87\xf5\x77\xbf\x08\x26\xd9\x7e\xa2\xd1\x84\xdd\x3e\x5c\x1e\xd3\xea\xcb\x0e\xac\xe0\xd6\x7a\x34\x3d\x8b\xa3\x20\xf8\xd6\xff\x76\xd9\xc1\x7f\x01\x00\x00\xff\xff\xea\x4f\x8c\x5c\x97\x0d\x00\x00") func templateMigrateSchemaTmplBytes() ([]byte, error) { return bindataRead( @@ -819,7 +830,7 @@ func templateMigrateSchemaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/migrate/schema.tmpl", size: 3595, mode: os.FileMode(420), modTime: time.Unix(1566995215, 0)} + info := bindataFileInfo{name: "template/migrate/schema.tmpl", size: 3479, mode: os.FileMode(420), modTime: time.Unix(1567076814, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -839,7 +850,7 @@ func templatePredicateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/predicate.tmpl", size: 1017, mode: os.FileMode(420), modTime: time.Unix(1566224088, 0)} + info := bindataFileInfo{name: "template/predicate.tmpl", size: 1017, mode: os.FileMode(420), modTime: time.Unix(1566238093, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -859,7 +870,7 @@ func templateTxTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/tx.tmpl", size: 3186, mode: os.FileMode(420), modTime: time.Unix(1566224088, 0)} + info := bindataFileInfo{name: "template/tx.tmpl", size: 3186, mode: os.FileMode(420), modTime: time.Unix(1566238093, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -879,7 +890,7 @@ func templateWhereTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/where.tmpl", size: 4903, mode: os.FileMode(420), modTime: time.Unix(1566475502, 0)} + info := bindataFileInfo{name: "template/where.tmpl", size: 4903, mode: os.FileMode(420), modTime: time.Unix(1566480918, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/migrate/schema.tmpl b/entc/gen/template/migrate/schema.tmpl index f026c731c..1c8d980d4 100644 --- a/entc/gen/template/migrate/schema.tmpl +++ b/entc/gen/template/migrate/schema.tmpl @@ -28,9 +28,7 @@ var ( {{- if $c.Nullable }} Nullable: {{ $c.Nullable }},{{ end }} {{- with $c.Size }} Size: {{ . }},{{ end }} {{- with $c.Attr }} Attr: "{{ . }}",{{ end }} - {{- if $c.HasDefault }} Default: {{ $node.Package }}.Default{{ pascal $c.Name }},{{ end }} - {{- with $c.Charset }} Charset: "{{ . }}",{{ end }} - {{- with $c.Collation }} Collation: "{{ . }}",{{ end }}}, + {{- if $c.HasDefault }} Default: {{ $node.Package }}.Default{{ pascal $c.Name }},{{ end }}}, {{- end }} } {{- $table := pascal $t.Name | printf "%sTable" }} diff --git a/entc/gen/type.go b/entc/gen/type.go index fdc5c51f5..a113ea405 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -416,12 +416,6 @@ func (f Field) Column() *schema.Column { if f.def.Size != nil { c.Size = *f.def.Size } - if f.def.Charset != nil { - c.Charset = *f.def.Charset - } - if f.def.Collation != nil { - c.Collation = *f.def.Collation - } } if f.Default && !f.IsTime() { // since this column is used only for codegen, the actual default diff --git a/entc/integration/ent/example_test.go b/entc/integration/ent/example_test.go index b84155c1d..919047aa0 100644 --- a/entc/integration/ent/example_test.go +++ b/entc/integration/ent/example_test.go @@ -124,7 +124,6 @@ func ExampleFile() { Create(). SetSize(1). SetName("string"). - SetText("string"). SetUser("string"). SetGroup("string"). SaveX(ctx) @@ -150,7 +149,6 @@ func ExampleFileType() { Create(). SetSize(1). SetName("string"). - SetText("string"). SetUser("string"). SetGroup("string"). SaveX(ctx) @@ -189,7 +187,6 @@ func ExampleGroup() { Create(). SetSize(1). SetName("string"). - SetText("string"). SetUser("string"). SetGroup("string"). SaveX(ctx) @@ -358,7 +355,6 @@ func ExampleUser() { Create(). SetSize(1). SetName("string"). - SetText("string"). SetUser("string"). SetGroup("string"). SaveX(ctx) diff --git a/entc/integration/ent/file.go b/entc/integration/ent/file.go index 86279c0bd..88b38707f 100644 --- a/entc/integration/ent/file.go +++ b/entc/integration/ent/file.go @@ -20,8 +20,6 @@ type File struct { Size int `json:"size,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` - // Text holds the value of the "text" field. - Text string `json:"text,omitempty"` // User holds the value of the "user" field. User *string `json:"user,omitempty"` // Group holds the value of the "group" field. @@ -34,7 +32,6 @@ func (f *File) FromRows(rows *sql.Rows) error { ID int Size sql.NullInt64 Name sql.NullString - Text sql.NullString User sql.NullString Group sql.NullString } @@ -43,7 +40,6 @@ func (f *File) FromRows(rows *sql.Rows) error { &vf.ID, &vf.Size, &vf.Name, - &vf.Text, &vf.User, &vf.Group, ); err != nil { @@ -52,7 +48,6 @@ func (f *File) FromRows(rows *sql.Rows) error { f.ID = strconv.Itoa(vf.ID) f.Size = int(vf.Size.Int64) f.Name = vf.Name.String - f.Text = vf.Text.String if vf.User.Valid { f.User = new(string) *f.User = vf.User.String @@ -71,7 +66,6 @@ func (f *File) FromResponse(res *gremlin.Response) error { ID string `json:"id,omitempty"` Size int `json:"size,omitempty"` Name string `json:"name,omitempty"` - Text string `json:"text,omitempty"` User *string `json:"user,omitempty"` Group string `json:"group,omitempty"` } @@ -81,7 +75,6 @@ func (f *File) FromResponse(res *gremlin.Response) error { f.ID = vf.ID f.Size = vf.Size f.Name = vf.Name - f.Text = vf.Text f.User = vf.User f.Group = vf.Group return nil @@ -122,7 +115,6 @@ func (f *File) String() string { buf.WriteString(fmt.Sprintf("id=%v", f.ID)) buf.WriteString(fmt.Sprintf(", size=%v", f.Size)) buf.WriteString(fmt.Sprintf(", name=%v", f.Name)) - buf.WriteString(fmt.Sprintf(", text=%v", f.Text)) if v := f.User; v != nil { buf.WriteString(fmt.Sprintf(", user=%v", *v)) } @@ -162,7 +154,6 @@ func (f *Files) FromResponse(res *gremlin.Response) error { ID string `json:"id,omitempty"` Size int `json:"size,omitempty"` Name string `json:"name,omitempty"` - Text string `json:"text,omitempty"` User *string `json:"user,omitempty"` Group string `json:"group,omitempty"` } @@ -174,7 +165,6 @@ func (f *Files) FromResponse(res *gremlin.Response) error { ID: v.ID, Size: v.Size, Name: v.Name, - Text: v.Text, User: v.User, Group: v.Group, }) diff --git a/entc/integration/ent/file/file.go b/entc/integration/ent/file/file.go index 2b2aa3c41..0196885b9 100644 --- a/entc/integration/ent/file/file.go +++ b/entc/integration/ent/file/file.go @@ -15,8 +15,6 @@ const ( FieldSize = "size" // FieldName holds the string denoting the name vertex property in the database. FieldName = "name" - // FieldText holds the string denoting the text vertex property in the database. - FieldText = "text" // FieldUser holds the string denoting the user vertex property in the database. FieldUser = "user" // FieldGroup holds the string denoting the group vertex property in the database. @@ -50,7 +48,6 @@ var Columns = []string{ FieldID, FieldSize, FieldName, - FieldText, FieldUser, FieldGroup, } diff --git a/entc/integration/ent/file/where.go b/entc/integration/ent/file/where.go index 512fff19d..85e4bc249 100644 --- a/entc/integration/ent/file/where.go +++ b/entc/integration/ent/file/where.go @@ -180,18 +180,6 @@ func Name(v string) predicate.File { ) } -// Text applies equality check predicate on the "text" field. It's identical to TextEQ. -func Text(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.EQ(v)) - }, - ) -} - // User applies equality check predicate on the "user" field. It's identical to UserEQ. func User(v string) predicate.File { return predicate.FilePerDialect( @@ -484,182 +472,6 @@ func NameHasSuffix(v string) predicate.File { ) } -// TextEQ applies the EQ predicate on the "text" field. -func TextEQ(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.EQ(v)) - }, - ) -} - -// TextNEQ applies the NEQ predicate on the "text" field. -func TextNEQ(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.NEQ(v)) - }, - ) -} - -// TextGT applies the GT predicate on the "text" field. -func TextGT(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.GT(v)) - }, - ) -} - -// TextGTE applies the GTE predicate on the "text" field. -func TextGTE(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.GTE(v)) - }, - ) -} - -// TextLT applies the LT predicate on the "text" field. -func TextLT(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.LT(v)) - }, - ) -} - -// TextLTE applies the LTE predicate on the "text" field. -func TextLTE(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.LTE(v)) - }, - ) -} - -// TextIn applies the In predicate on the "text" field. -func TextIn(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(FieldText), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.Within(v...)) - }, - ) -} - -// TextNotIn applies the NotIn predicate on the "text" field. -func TextNotIn(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(FieldText), v...)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.Without(v...)) - }, - ) -} - -// TextContains applies the Contains predicate on the "text" field. -func TextContains(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.Containing(v)) - }, - ) -} - -// TextHasPrefix applies the HasPrefix predicate on the "text" field. -func TextHasPrefix(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.StartingWith(v)) - }, - ) -} - -// TextHasSuffix applies the HasSuffix predicate on the "text" field. -func TextHasSuffix(v string) predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldText), v)) - }, - func(t *dsl.Traversal) { - t.Has(Label, FieldText, p.EndingWith(v)) - }, - ) -} - -// TextIsNil applies the IsNil predicate on the "text" field. -func TextIsNil() predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldText))) - }, - func(t *dsl.Traversal) { - t.HasLabel(Label).HasNot(FieldText) - }, - ) -} - -// TextNotNil applies the NotNil predicate on the "text" field. -func TextNotNil() predicate.File { - return predicate.FilePerDialect( - func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldText))) - }, - func(t *dsl.Traversal) { - t.HasLabel(Label).Has(FieldText) - }, - ) -} - // UserEQ applies the EQ predicate on the "user" field. func UserEQ(v string) predicate.File { return predicate.FilePerDialect( diff --git a/entc/integration/ent/file_create.go b/entc/integration/ent/file_create.go index 895a187a9..c76302388 100644 --- a/entc/integration/ent/file_create.go +++ b/entc/integration/ent/file_create.go @@ -15,9 +15,7 @@ import ( "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/gremlin" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl" - "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/__" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/g" - "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/p" "github.com/facebookincubator/ent/dialect/sql" ) @@ -26,7 +24,6 @@ type FileCreate struct { config size *int name *string - text *string user *string group *string owner map[string]struct{} @@ -53,20 +50,6 @@ func (fc *FileCreate) SetName(s string) *FileCreate { return fc } -// SetText sets the text field. -func (fc *FileCreate) SetText(s string) *FileCreate { - fc.text = &s - return fc -} - -// SetNillableText sets the text field if the given value is not nil. -func (fc *FileCreate) SetNillableText(s *string) *FileCreate { - if s != nil { - fc.SetText(*s) - } - return fc -} - // SetUser sets the user field. func (fc *FileCreate) SetUser(s string) *FileCreate { fc.user = &s @@ -194,10 +177,6 @@ func (fc *FileCreate) sqlSave(ctx context.Context) (*File, error) { builder.Set(file.FieldName, *fc.name) f.Name = *fc.name } - if fc.text != nil { - builder.Set(file.FieldText, *fc.text) - f.Text = *fc.text - } if fc.user != nil { builder.Set(file.FieldUser, *fc.user) f.User = fc.user @@ -268,11 +247,6 @@ func (fc *FileCreate) gremlinSave(ctx context.Context) (*File, error) { } func (fc *FileCreate) gremlin() *dsl.Traversal { - type constraint struct { - pred *dsl.Traversal // constraint predicate. - test *dsl.Traversal // test matches and its constant. - } - constraints := make([]*constraint, 0, 1) v := g.AddV(file.Label) if fc.size != nil { v.Property(dsl.Single, file.FieldSize, *fc.size) @@ -280,13 +254,6 @@ func (fc *FileCreate) gremlin() *dsl.Traversal { if fc.name != nil { v.Property(dsl.Single, file.FieldName, *fc.name) } - if fc.text != nil { - constraints = append(constraints, &constraint{ - pred: g.V().Has(file.Label, file.FieldText, *fc.text).Count(), - test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(file.Label, file.FieldText, *fc.text)), - }) - v.Property(dsl.Single, file.FieldText, *fc.text) - } if fc.user != nil { v.Property(dsl.Single, file.FieldUser, *fc.user) } @@ -299,12 +266,5 @@ func (fc *FileCreate) gremlin() *dsl.Traversal { for id := range fc._type { v.AddE(filetype.FilesLabel).From(g.V(id)).InV() } - if len(constraints) == 0 { - return v.ValueMap(true) - } - tr := constraints[0].pred.Coalesce(constraints[0].test, v.ValueMap(true)) - for _, cr := range constraints[1:] { - tr = cr.pred.Coalesce(cr.test, tr) - } - return tr + return v.ValueMap(true) } diff --git a/entc/integration/ent/file_update.go b/entc/integration/ent/file_update.go index d4ae043b5..a20c003a5 100644 --- a/entc/integration/ent/file_update.go +++ b/entc/integration/ent/file_update.go @@ -16,9 +16,7 @@ import ( "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/gremlin" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl" - "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/__" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/g" - "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/p" "github.com/facebookincubator/ent/dialect/sql" ) @@ -27,7 +25,6 @@ type FileUpdate struct { config size *int name *string - text *string user *string group *string owner map[string]struct{} @@ -63,20 +60,6 @@ func (fu *FileUpdate) SetName(s string) *FileUpdate { return fu } -// SetText sets the text field. -func (fu *FileUpdate) SetText(s string) *FileUpdate { - fu.text = &s - return fu -} - -// SetNillableText sets the text field if the given value is not nil. -func (fu *FileUpdate) SetNillableText(s *string) *FileUpdate { - if s != nil { - fu.SetText(*s) - } - return fu -} - // SetUser sets the user field. func (fu *FileUpdate) SetUser(s string) *FileUpdate { fu.user = &s @@ -246,10 +229,6 @@ func (fu *FileUpdate) sqlSave(ctx context.Context) (n int, err error) { update = true builder.Set(file.FieldName, *fu.name) } - if fu.text != nil { - update = true - builder.Set(file.FieldText, *fu.text) - } if fu.user != nil { update = true builder.Set(file.FieldUser, *fu.user) @@ -333,11 +312,6 @@ func (fu *FileUpdate) gremlinSave(ctx context.Context) (int, error) { } func (fu *FileUpdate) gremlin() *dsl.Traversal { - type constraint struct { - pred *dsl.Traversal // constraint predicate. - test *dsl.Traversal // test matches and its constant. - } - constraints := make([]*constraint, 0, 1) v := g.V().HasLabel(file.Label) for _, p := range fu.predicates { p(v) @@ -354,13 +328,6 @@ func (fu *FileUpdate) gremlin() *dsl.Traversal { if fu.name != nil { v.Property(dsl.Single, file.FieldName, *fu.name) } - if fu.text != nil { - constraints = append(constraints, &constraint{ - pred: g.V().Has(file.Label, file.FieldText, *fu.text).Count(), - test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(file.Label, file.FieldText, *fu.text)), - }) - v.Property(dsl.Single, file.FieldText, *fu.text) - } if fu.user != nil { v.Property(dsl.Single, file.FieldUser, *fu.user) } @@ -382,16 +349,6 @@ func (fu *FileUpdate) gremlin() *dsl.Traversal { v.AddE(filetype.FilesLabel).From(g.V(id)).InV() } v.Count() - if len(constraints) > 0 { - constraints = append(constraints, &constraint{ - pred: rv.Count(), - test: __.Is(p.GT(1)).Constant(&ErrConstraintFailed{msg: "update traversal contains more than one vertex"}), - }) - v = constraints[0].pred.Coalesce(constraints[0].test, v) - for _, cr := range constraints[1:] { - v = cr.pred.Coalesce(cr.test, v) - } - } trs = append(trs, v) return dsl.Join(trs...) } @@ -402,7 +359,6 @@ type FileUpdateOne struct { id string size *int name *string - text *string user *string group *string owner map[string]struct{} @@ -431,20 +387,6 @@ func (fuo *FileUpdateOne) SetName(s string) *FileUpdateOne { return fuo } -// SetText sets the text field. -func (fuo *FileUpdateOne) SetText(s string) *FileUpdateOne { - fuo.text = &s - return fuo -} - -// SetNillableText sets the text field if the given value is not nil. -func (fuo *FileUpdateOne) SetNillableText(s *string) *FileUpdateOne { - if s != nil { - fuo.SetText(*s) - } - return fuo -} - // SetUser sets the user field. func (fuo *FileUpdateOne) SetUser(s string) *FileUpdateOne { fuo.user = &s @@ -619,11 +561,6 @@ func (fuo *FileUpdateOne) sqlSave(ctx context.Context) (f *File, err error) { builder.Set(file.FieldName, *fuo.name) f.Name = *fuo.name } - if fuo.text != nil { - update = true - builder.Set(file.FieldText, *fuo.text) - f.Text = *fuo.text - } if fuo.user != nil { update = true builder.Set(file.FieldUser, *fuo.user) @@ -713,11 +650,6 @@ func (fuo *FileUpdateOne) gremlinSave(ctx context.Context) (*File, error) { } func (fuo *FileUpdateOne) gremlin(id string) *dsl.Traversal { - type constraint struct { - pred *dsl.Traversal // constraint predicate. - test *dsl.Traversal // test matches and its constant. - } - constraints := make([]*constraint, 0, 1) v := g.V(id) var ( rv = v.Clone() @@ -731,13 +663,6 @@ func (fuo *FileUpdateOne) gremlin(id string) *dsl.Traversal { if fuo.name != nil { v.Property(dsl.Single, file.FieldName, *fuo.name) } - if fuo.text != nil { - constraints = append(constraints, &constraint{ - pred: g.V().Has(file.Label, file.FieldText, *fuo.text).Count(), - test: __.Is(p.NEQ(0)).Constant(NewErrUniqueField(file.Label, file.FieldText, *fuo.text)), - }) - v.Property(dsl.Single, file.FieldText, *fuo.text) - } if fuo.user != nil { v.Property(dsl.Single, file.FieldUser, *fuo.user) } @@ -759,12 +684,6 @@ func (fuo *FileUpdateOne) gremlin(id string) *dsl.Traversal { v.AddE(filetype.FilesLabel).From(g.V(id)).InV() } v.ValueMap(true) - if len(constraints) > 0 { - v = constraints[0].pred.Coalesce(constraints[0].test, v) - for _, cr := range constraints[1:] { - v = cr.pred.Coalesce(cr.test, v) - } - } trs = append(trs, v) return dsl.Join(trs...) } diff --git a/entc/integration/ent/migrate/schema.go b/entc/integration/ent/migrate/schema.go index cd7429725..beb5e8db6 100644 --- a/entc/integration/ent/migrate/schema.go +++ b/entc/integration/ent/migrate/schema.go @@ -80,7 +80,6 @@ var ( {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "size", Type: field.TypeInt, Default: file.DefaultSize}, {Name: "name", Type: field.TypeString}, - {Name: "text", Type: field.TypeString, Unique: true, Nullable: true, Collation: "utf8mb4_general_ci"}, {Name: "user", Type: field.TypeString, Nullable: true}, {Name: "group", Type: field.TypeString, Nullable: true}, {Name: "type_id", Type: field.TypeInt, Nullable: true}, @@ -95,21 +94,21 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "files_file_types_files", - Columns: []*schema.Column{FilesColumns[6]}, + Columns: []*schema.Column{FilesColumns[5]}, RefColumns: []*schema.Column{FileTypesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "files_groups_files", - Columns: []*schema.Column{FilesColumns[7]}, + Columns: []*schema.Column{FilesColumns[6]}, RefColumns: []*schema.Column{GroupsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "files_users_files", - Columns: []*schema.Column{FilesColumns[8]}, + Columns: []*schema.Column{FilesColumns[7]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, @@ -124,12 +123,12 @@ var ( { Name: "name_user", Unique: true, - Columns: []*schema.Column{FilesColumns[2], FilesColumns[4]}, + Columns: []*schema.Column{FilesColumns[2], FilesColumns[3]}, }, { Name: "name_owner_id_type_id", Unique: true, - Columns: []*schema.Column{FilesColumns[2], FilesColumns[8], FilesColumns[6]}, + Columns: []*schema.Column{FilesColumns[2], FilesColumns[7], FilesColumns[5]}, }, }, } diff --git a/entc/integration/ent/schema/file.go b/entc/integration/ent/schema/file.go index 822debba1..d1194b41f 100644 --- a/entc/integration/ent/schema/file.go +++ b/entc/integration/ent/schema/file.go @@ -25,10 +25,6 @@ func (File) Fields() []ent.Field { Default(math.MaxInt32). Positive(), field.String("name"), - field.String("text"). - Collation("utf8mb4_general_ci"). - Optional(). - Unique(), field.String("user"). Optional(). Nillable(), diff --git a/entc/integration/integration_test.go b/entc/integration/integration_test.go index 4206232a8..e8d532bfc 100644 --- a/entc/integration/integration_test.go +++ b/entc/integration/integration_test.go @@ -38,7 +38,7 @@ func TestSQLite(t *testing.T) { defer drv.Close() client := ent.NewClient(ent.Driver(drv)) require.NoError(t, client.Schema.Create(context.Background())) - for _, tt := range tests[1:] { + for _, tt := range tests { name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name() t.Run(name[strings.LastIndex(name, ".")+1:], func(t *testing.T) { drop(t, client) @@ -78,7 +78,7 @@ func TestGremlin(t *testing.T) { require.NoError(t, err) client := ent.NewClient(ent.Driver(gremlin.NewDriver(c))) // run all tests except transaction and index tests. - for _, tt := range tests[3:] { + for _, tt := range tests[2:] { name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name() t.Run(name[strings.LastIndex(name, ".")+1:], func(t *testing.T) { drop(t, client) @@ -89,14 +89,12 @@ func TestGremlin(t *testing.T) { // tests for all drivers to run. var tests = []func(*testing.T, *ent.Client){ - Collation, Tx, Indexes, Types, Clone, Sanity, Paging, - Charset, Relation, Predicate, UniqueConstraint, @@ -233,33 +231,6 @@ func Paging(t *testing.T, client *ent.Client) { } } -func Charset(t *testing.T, client *ent.Client) { - require := require.New(t) - ctx := context.Background() - f1 := client.File.Create().SetName("אריאל").SetSize(10).SaveX(ctx) - f2 := client.File.Create().SetName("נטי").SetSize(10).SaveX(ctx) - f3 := client.File.Create().SetName("Ariel").SetSize(10).SaveX(ctx) - f4 := client.File.Create().SetName("Nati").SetSize(10).SaveX(ctx) - require.Equal("אריאל", f1.Name) - require.Equal("נטי", f2.Name) - require.Equal("Ariel", f3.Name) - require.Equal("Nati", f4.Name) -} - -func Collation(t *testing.T, client *ent.Client) { - require := require.New(t) - ctx := context.Background() - _ = client.File.Create().SetName("Foo").SetText("hello world").SaveX(ctx) - query := client.File.Query().Where(file.Name("foo")) - require.False(query.ExistX(ctx)) - require.Nil(query.FirstX(ctx)) - f := client.File.Query().Where(file.Text("Hello WoRLD")).OnlyX(ctx) - require.Equal("Foo", f.Name) - require.Equal("hello world", f.Text) - _, err := client.File.Create().SetName("Bar").SetText("Hello World").Save(ctx) - require.Error(err, "text field uses case insensitive collation") -} - func Predicate(t *testing.T, client *ent.Client) { require := require.New(t) ctx := context.Background() diff --git a/entc/integration/migrate/entv1/example_test.go b/entc/integration/migrate/entv1/example_test.go index 0c494976a..29cce6cc3 100644 --- a/entc/integration/migrate/entv1/example_test.go +++ b/entc/integration/migrate/entv1/example_test.go @@ -34,7 +34,6 @@ func ExampleUser() { SetAge(1). SetName("string"). SetAddress("string"). - SetRole("string"). 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 3ee8e2957..87e5d8f80 100644 --- a/entc/integration/migrate/entv1/migrate/schema.go +++ b/entc/integration/migrate/entv1/migrate/schema.go @@ -14,7 +14,6 @@ var ( {Name: "age", Type: field.TypeInt32}, {Name: "name", Type: field.TypeString, Size: 10}, {Name: "address", Type: field.TypeString, Nullable: true}, - {Name: "role", Type: field.TypeString, Nullable: true}, } // 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 722ce6a3b..c64d57a1e 100644 --- a/entc/integration/migrate/entv1/schema/user.go +++ b/entc/integration/migrate/entv1/schema/user.go @@ -21,7 +21,6 @@ func (User) Fields() []ent.Field { field.Int32("age"), field.String("name").MaxLen(10), field.String("address").Optional(), - field.String("role").Optional(), } } diff --git a/entc/integration/migrate/entv1/user.go b/entc/integration/migrate/entv1/user.go index 578671855..0c5e81ef5 100644 --- a/entc/integration/migrate/entv1/user.go +++ b/entc/integration/migrate/entv1/user.go @@ -20,8 +20,6 @@ type User struct { Name string `json:"name,omitempty"` // Address holds the value of the "address" field. Address string `json:"address,omitempty"` - // Role holds the value of the "role" field. - Role string `json:"role,omitempty"` } // FromRows scans the sql response data into User. @@ -31,7 +29,6 @@ func (u *User) FromRows(rows *sql.Rows) error { Age sql.NullInt64 Name sql.NullString Address sql.NullString - Role sql.NullString } // the order here should be the same as in the `user.Columns`. if err := rows.Scan( @@ -39,7 +36,6 @@ func (u *User) FromRows(rows *sql.Rows) error { &vu.Age, &vu.Name, &vu.Address, - &vu.Role, ); err != nil { return err } @@ -47,7 +43,6 @@ func (u *User) FromRows(rows *sql.Rows) error { u.Age = int32(vu.Age.Int64) u.Name = vu.Name.String u.Address = vu.Address.String - u.Role = vu.Role.String return nil } @@ -77,7 +72,6 @@ func (u *User) String() string { buf.WriteString(fmt.Sprintf(", age=%v", u.Age)) buf.WriteString(fmt.Sprintf(", name=%v", u.Name)) buf.WriteString(fmt.Sprintf(", address=%v", u.Address)) - buf.WriteString(fmt.Sprintf(", role=%v", u.Role)) buf.WriteString(")") return buf.String() } diff --git a/entc/integration/migrate/entv1/user/user.go b/entc/integration/migrate/entv1/user/user.go index 5950d4090..98750a071 100644 --- a/entc/integration/migrate/entv1/user/user.go +++ b/entc/integration/migrate/entv1/user/user.go @@ -17,8 +17,6 @@ const ( FieldName = "name" // FieldAddress holds the string denoting the address vertex property in the database. FieldAddress = "address" - // FieldRole holds the string denoting the role vertex property in the database. - FieldRole = "role" // Table holds the table name of the user in the database. Table = "users" @@ -30,7 +28,6 @@ var Columns = []string{ FieldAge, FieldName, FieldAddress, - FieldRole, } var ( diff --git a/entc/integration/migrate/entv1/user/where.go b/entc/integration/migrate/entv1/user/where.go index 476935eb7..719253a6c 100644 --- a/entc/integration/migrate/entv1/user/where.go +++ b/entc/integration/migrate/entv1/user/where.go @@ -136,15 +136,6 @@ func Address(v string) predicate.User { ) } -// Role applies equality check predicate on the "role" field. It's identical to RoleEQ. -func Role(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRole), v)) - }, - ) -} - // AgeEQ applies the EQ predicate on the "age" field. func AgeEQ(v int32) predicate.User { return predicate.User( @@ -529,161 +520,6 @@ func AddressContainsFold(v string) predicate.User { ) } -// RoleEQ applies the EQ predicate on the "role" field. -func RoleEQ(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRole), v)) - }, - ) -} - -// RoleNEQ applies the NEQ predicate on the "role" field. -func RoleNEQ(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldRole), v)) - }, - ) -} - -// RoleGT applies the GT predicate on the "role" field. -func RoleGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRole), v)) - }, - ) -} - -// RoleGTE applies the GTE predicate on the "role" field. -func RoleGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRole), v)) - }, - ) -} - -// RoleLT applies the LT predicate on the "role" field. -func RoleLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRole), v)) - }, - ) -} - -// RoleLTE applies the LTE predicate on the "role" field. -func RoleLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRole), v)) - }, - ) -} - -// RoleIn applies the In predicate on the "role" field. -func RoleIn(vs ...string) 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(FieldRole), v...)) - }, - ) -} - -// RoleNotIn applies the NotIn predicate on the "role" field. -func RoleNotIn(vs ...string) 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(FieldRole), v...)) - }, - ) -} - -// RoleContains applies the Contains predicate on the "role" field. -func RoleContains(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldRole), v)) - }, - ) -} - -// RoleHasPrefix applies the HasPrefix predicate on the "role" field. -func RoleHasPrefix(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldRole), v)) - }, - ) -} - -// RoleHasSuffix applies the HasSuffix predicate on the "role" field. -func RoleHasSuffix(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldRole), v)) - }, - ) -} - -// RoleIsNil applies the IsNil predicate on the "role" field. -func RoleIsNil() predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldRole))) - }, - ) -} - -// RoleNotNil applies the NotNil predicate on the "role" field. -func RoleNotNil() predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldRole))) - }, - ) -} - -// RoleEqualFold applies the EqualFold predicate on the "role" field. -func RoleEqualFold(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldRole), v)) - }, - ) -} - -// RoleContainsFold applies the ContainsFold predicate on the "role" field. -func RoleContainsFold(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldRole), v)) - }, - ) -} - // 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 e8f1492e0..62d1713ff 100644 --- a/entc/integration/migrate/entv1/user_create.go +++ b/entc/integration/migrate/entv1/user_create.go @@ -18,7 +18,6 @@ type UserCreate struct { age *int32 name *string address *string - role *string } // SetAge sets the age field. @@ -47,20 +46,6 @@ func (uc *UserCreate) SetNillableAddress(s *string) *UserCreate { return uc } -// SetRole sets the role field. -func (uc *UserCreate) SetRole(s string) *UserCreate { - uc.role = &s - return uc -} - -// SetNillableRole sets the role field if the given value is not nil. -func (uc *UserCreate) SetNillableRole(s *string) *UserCreate { - if s != nil { - uc.SetRole(*s) - } - return uc -} - // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { if uc.age == nil { @@ -106,10 +91,6 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { builder.Set(user.FieldAddress, *uc.address) u.Address = *uc.address } - if uc.role != nil { - builder.Set(user.FieldRole, *uc.role) - u.Role = *uc.role - } 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 f0a2794ca..43137a596 100644 --- a/entc/integration/migrate/entv1/user_update.go +++ b/entc/integration/migrate/entv1/user_update.go @@ -18,7 +18,6 @@ type UserUpdate struct { age *int32 name *string address *string - role *string predicates []predicate.User } @@ -54,20 +53,6 @@ func (uu *UserUpdate) SetNillableAddress(s *string) *UserUpdate { return uu } -// SetRole sets the role field. -func (uu *UserUpdate) SetRole(s string) *UserUpdate { - uu.role = &s - return uu -} - -// SetNillableRole sets the role field if the given value is not nil. -func (uu *UserUpdate) SetNillableRole(s *string) *UserUpdate { - if s != nil { - uu.SetRole(*s) - } - 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 { @@ -144,10 +129,6 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { update = true builder.Set(user.FieldAddress, *uu.address) } - if uu.role != nil { - update = true - builder.Set(user.FieldRole, *uu.role) - } if update { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { @@ -167,7 +148,6 @@ type UserUpdateOne struct { age *int32 name *string address *string - role *string } // SetAge sets the age field. @@ -196,20 +176,6 @@ func (uuo *UserUpdateOne) SetNillableAddress(s *string) *UserUpdateOne { return uuo } -// SetRole sets the role field. -func (uuo *UserUpdateOne) SetRole(s string) *UserUpdateOne { - uuo.role = &s - return uuo -} - -// SetNillableRole sets the role field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableRole(s *string) *UserUpdateOne { - if s != nil { - uuo.SetRole(*s) - } - return uuo -} - // Save executes the query and returns the updated entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { if uuo.name != nil { @@ -292,11 +258,6 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (u *User, err error) { builder.Set(user.FieldAddress, *uuo.address) u.Address = *uuo.address } - if uuo.role != nil { - update = true - builder.Set(user.FieldRole, *uuo.role) - u.Role = *uuo.role - } if update { 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 b0022a447..69bfe3537 100644 --- a/entc/integration/migrate/entv2/example_test.go +++ b/entc/integration/migrate/entv2/example_test.go @@ -82,7 +82,6 @@ func ExampleUser() { SetPhone("string"). SetBuffer([]byte{}). SetTitle("string"). - SetRole("string"). SaveX(ctx) log.Println("user created:", u) diff --git a/entc/integration/migrate/entv2/migrate/schema.go b/entc/integration/migrate/entv2/migrate/schema.go index 5c6c46ec7..ba85092c1 100644 --- a/entc/integration/migrate/entv2/migrate/schema.go +++ b/entc/integration/migrate/entv2/migrate/schema.go @@ -39,7 +39,6 @@ var ( {Name: "phone", Type: field.TypeString}, {Name: "buffer", Type: field.TypeBytes, Default: user.DefaultBuffer}, {Name: "title", Type: field.TypeString, Default: user.DefaultTitle}, - {Name: "role", Type: field.TypeString, Nullable: true, Collation: "utf8mb4_general_ci"}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ diff --git a/entc/integration/migrate/entv2/schema/user.go b/entc/integration/migrate/entv2/schema/user.go index b227f6ed1..28ebb8083 100644 --- a/entc/integration/migrate/entv2/schema/user.go +++ b/entc/integration/migrate/entv2/schema/user.go @@ -31,10 +31,6 @@ func (User) Fields() []ent.Field { // all existing rows. field.String("title"). Default("SWE"), - // adding column collation - field.String("role"). - Collation("utf8mb4_general_ci"). - Optional(), // deleting the `address` column. } } diff --git a/entc/integration/migrate/entv2/user.go b/entc/integration/migrate/entv2/user.go index d143b861f..5dfc1f711 100644 --- a/entc/integration/migrate/entv2/user.go +++ b/entc/integration/migrate/entv2/user.go @@ -24,8 +24,6 @@ type User struct { Buffer []byte `json:"buffer,omitempty"` // Title holds the value of the "title" field. Title string `json:"title,omitempty"` - // Role holds the value of the "role" field. - Role string `json:"role,omitempty"` } // FromRows scans the sql response data into User. @@ -37,7 +35,6 @@ func (u *User) FromRows(rows *sql.Rows) error { Phone sql.NullString Buffer []byte Title sql.NullString - Role sql.NullString } // the order here should be the same as in the `user.Columns`. if err := rows.Scan( @@ -47,7 +44,6 @@ func (u *User) FromRows(rows *sql.Rows) error { &vu.Phone, &vu.Buffer, &vu.Title, - &vu.Role, ); err != nil { return err } @@ -57,7 +53,6 @@ func (u *User) FromRows(rows *sql.Rows) error { u.Phone = vu.Phone.String u.Buffer = vu.Buffer u.Title = vu.Title.String - u.Role = vu.Role.String return nil } @@ -89,7 +84,6 @@ func (u *User) String() string { buf.WriteString(fmt.Sprintf(", phone=%v", u.Phone)) buf.WriteString(fmt.Sprintf(", buffer=%v", u.Buffer)) buf.WriteString(fmt.Sprintf(", title=%v", u.Title)) - buf.WriteString(fmt.Sprintf(", role=%v", u.Role)) buf.WriteString(")") return buf.String() } diff --git a/entc/integration/migrate/entv2/user/user.go b/entc/integration/migrate/entv2/user/user.go index c7833e970..51e286f75 100644 --- a/entc/integration/migrate/entv2/user/user.go +++ b/entc/integration/migrate/entv2/user/user.go @@ -21,8 +21,6 @@ const ( FieldBuffer = "buffer" // FieldTitle holds the string denoting the title vertex property in the database. FieldTitle = "title" - // FieldRole holds the string denoting the role vertex property in the database. - FieldRole = "role" // Table holds the table name of the user in the database. Table = "users" @@ -36,7 +34,6 @@ var Columns = []string{ FieldPhone, FieldBuffer, FieldTitle, - FieldRole, } var ( diff --git a/entc/integration/migrate/entv2/user/where.go b/entc/integration/migrate/entv2/user/where.go index 8c95e17c4..67ca2ed7b 100644 --- a/entc/integration/migrate/entv2/user/where.go +++ b/entc/integration/migrate/entv2/user/where.go @@ -154,15 +154,6 @@ func Title(v string) predicate.User { ) } -// Role applies equality check predicate on the "role" field. It's identical to RoleEQ. -func Role(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRole), v)) - }, - ) -} - // AgeEQ applies the EQ predicate on the "age" field. func AgeEQ(v int) predicate.User { return predicate.User( @@ -758,161 +749,6 @@ func TitleContainsFold(v string) predicate.User { ) } -// RoleEQ applies the EQ predicate on the "role" field. -func RoleEQ(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRole), v)) - }, - ) -} - -// RoleNEQ applies the NEQ predicate on the "role" field. -func RoleNEQ(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldRole), v)) - }, - ) -} - -// RoleGT applies the GT predicate on the "role" field. -func RoleGT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRole), v)) - }, - ) -} - -// RoleGTE applies the GTE predicate on the "role" field. -func RoleGTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRole), v)) - }, - ) -} - -// RoleLT applies the LT predicate on the "role" field. -func RoleLT(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRole), v)) - }, - ) -} - -// RoleLTE applies the LTE predicate on the "role" field. -func RoleLTE(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRole), v)) - }, - ) -} - -// RoleIn applies the In predicate on the "role" field. -func RoleIn(vs ...string) 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(FieldRole), v...)) - }, - ) -} - -// RoleNotIn applies the NotIn predicate on the "role" field. -func RoleNotIn(vs ...string) 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(FieldRole), v...)) - }, - ) -} - -// RoleContains applies the Contains predicate on the "role" field. -func RoleContains(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldRole), v)) - }, - ) -} - -// RoleHasPrefix applies the HasPrefix predicate on the "role" field. -func RoleHasPrefix(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldRole), v)) - }, - ) -} - -// RoleHasSuffix applies the HasSuffix predicate on the "role" field. -func RoleHasSuffix(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldRole), v)) - }, - ) -} - -// RoleIsNil applies the IsNil predicate on the "role" field. -func RoleIsNil() predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldRole))) - }, - ) -} - -// RoleNotNil applies the NotNil predicate on the "role" field. -func RoleNotNil() predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldRole))) - }, - ) -} - -// RoleEqualFold applies the EqualFold predicate on the "role" field. -func RoleEqualFold(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldRole), v)) - }, - ) -} - -// RoleContainsFold applies the ContainsFold predicate on the "role" field. -func RoleContainsFold(v string) predicate.User { - return predicate.User( - func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldRole), v)) - }, - ) -} - // 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 31302c05f..f8b08fc5d 100644 --- a/entc/integration/migrate/entv2/user_create.go +++ b/entc/integration/migrate/entv2/user_create.go @@ -19,7 +19,6 @@ type UserCreate struct { phone *string buffer *[]byte title *string - role *string } // SetAge sets the age field. @@ -60,20 +59,6 @@ func (uc *UserCreate) SetNillableTitle(s *string) *UserCreate { return uc } -// SetRole sets the role field. -func (uc *UserCreate) SetRole(s string) *UserCreate { - uc.role = &s - return uc -} - -// SetNillableRole sets the role field if the given value is not nil. -func (uc *UserCreate) SetNillableRole(s *string) *UserCreate { - if s != nil { - uc.SetRole(*s) - } - return uc -} - // Save creates the User in the database. func (uc *UserCreate) Save(ctx context.Context) (*User, error) { if uc.age == nil { @@ -135,10 +120,6 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { builder.Set(user.FieldTitle, *uc.title) u.Title = *uc.title } - if uc.role != nil { - builder.Set(user.FieldRole, *uc.role) - u.Role = *uc.role - } 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 db8a1422f..0c9ba57e9 100644 --- a/entc/integration/migrate/entv2/user_update.go +++ b/entc/integration/migrate/entv2/user_update.go @@ -20,7 +20,6 @@ type UserUpdate struct { phone *string buffer *[]byte title *string - role *string predicates []predicate.User } @@ -68,20 +67,6 @@ func (uu *UserUpdate) SetNillableTitle(s *string) *UserUpdate { return uu } -// SetRole sets the role field. -func (uu *UserUpdate) SetRole(s string) *UserUpdate { - uu.role = &s - return uu -} - -// SetNillableRole sets the role field if the given value is not nil. -func (uu *UserUpdate) SetNillableRole(s *string) *UserUpdate { - if s != nil { - uu.SetRole(*s) - } - 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) { return uu.sqlSave(ctx) @@ -161,10 +146,6 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { update = true builder.Set(user.FieldTitle, *uu.title) } - if uu.role != nil { - update = true - builder.Set(user.FieldRole, *uu.role) - } if update { query, args := builder.Query() if err := tx.Exec(ctx, query, args, &res); err != nil { @@ -186,7 +167,6 @@ type UserUpdateOne struct { phone *string buffer *[]byte title *string - role *string } // SetAge sets the age field. @@ -227,20 +207,6 @@ func (uuo *UserUpdateOne) SetNillableTitle(s *string) *UserUpdateOne { return uuo } -// SetRole sets the role field. -func (uuo *UserUpdateOne) SetRole(s string) *UserUpdateOne { - uuo.role = &s - return uuo -} - -// SetNillableRole sets the role field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableRole(s *string) *UserUpdateOne { - if s != nil { - uuo.SetRole(*s) - } - return uuo -} - // Save executes the query and returns the updated entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { return uuo.sqlSave(ctx) @@ -328,11 +294,6 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (u *User, err error) { builder.Set(user.FieldTitle, *uuo.title) u.Title = *uuo.title } - if uuo.role != nil { - update = true - builder.Set(user.FieldRole, *uuo.role) - u.Role = *uuo.role - } if update { 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 d56da9fe5..9fcb5894d 100644 --- a/entc/integration/migrate/migrate_test.go +++ b/entc/integration/migrate/migrate_test.go @@ -12,12 +12,9 @@ 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" - "github.com/stretchr/testify/assert" - _ "github.com/go-sql-driver/mysql" _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" @@ -54,7 +51,6 @@ func TestMySQL(t *testing.T) { idRange(t, clientv2.Pet.Create().SaveX(ctx).ID, 2<<32-1, 3<<32) // sql specific predicates. - Collation(t, clientv2) EqualFold(t, clientv2) ContainsFold(t, clientv2) }) @@ -85,15 +81,9 @@ func TestSQLite(t *testing.T) { func SanityV1(t *testing.T, client *entv1.Client) { ctx := context.Background() - u := client.User.Create().SetAge(1).SetName("foo").SetRole("admin").SaveX(ctx) + u := client.User.Create().SetAge(1).SetName("foo").SaveX(ctx) require.EqualValues(t, 1, u.Age) require.Equal(t, "foo", u.Name) - require.Equal(t, "admin", u.Role) - - u = client.User.Create().SetAge(5).SetName("bar").SetRole("Admin").SaveX(ctx) - require.EqualValues(t, 5, u.Age) - require.Equal(t, "bar", u.Name) - require.Equal(t, "Admin", u.Role) _, err := client.User.Create().SetAge(2).SetName("foobarbazqux").Save(ctx) require.Error(t, err, "name is limited to 10 chars") @@ -102,14 +92,6 @@ func SanityV1(t *testing.T, client *entv1.Client) { client.User.Create().SetAge(3).SetName("foo").SetAddress("tlv").SaveX(ctx) _, err = client.User.Create().SetAge(4).SetName("foo").SetAddress("tlv").Save(ctx) require.Error(t, err) - - // default role collation is case sensitive - c := client.User.Query().Where(userv1.Role("admin")).CountX(ctx) - assert.Equal(t, 1, c) - c = client.User.Query().Where(userv1.Role("Admin")).CountX(ctx) - assert.Equal(t, 1, c) - c = client.User.Query().Where(userv1.Role("ADMIN")).CountX(ctx) - assert.Zero(t, c) } func SanityV2(t *testing.T, client *entv2.Client) { @@ -137,11 +119,6 @@ func SanityV2(t *testing.T, client *entv2.Client) { ) } -func Collation(t *testing.T, client *entv2.Client) { - t.Log("testing case insensitive collation update on sql specific dialects") - require.Equal(t, 2, client.User.Query().Where(user.Role("ADMIN")).CountX(context.Background())) -} - func EqualFold(t *testing.T, client *entv2.Client) { ctx := context.Background() t.Log("testing equal-fold on sql specific dialects") diff --git a/entc/load/bindata.go b/entc/load/bindata.go index d673a93c7..65fd237d8 100644 --- a/entc/load/bindata.go +++ b/entc/load/bindata.go @@ -1,4 +1,4 @@ -// Code generated by go-bindata. (@generated) DO NOT EDIT. +// Package load Code generated by go-bindata. (@generated) DO NOT EDIT. // sources: // template/main.tmpl // schema.go @@ -48,21 +48,32 @@ type bindataFileInfo struct { modTime time.Time } +// Name return file name func (fi bindataFileInfo) Name() string { return fi.name } + +// Size return file size func (fi bindataFileInfo) Size() int64 { return fi.size } + +// Mode return file mode func (fi bindataFileInfo) Mode() os.FileMode { return fi.mode } + +// Mode return file modify time func (fi bindataFileInfo) ModTime() time.Time { return fi.modTime } + +// IsDir return file whether a directory func (fi bindataFileInfo) IsDir() bool { - return false + return fi.mode&os.ModeDir != 0 } + +// Sys return file is sys mode func (fi bindataFileInfo) Sys() interface{} { return nil } @@ -82,12 +93,12 @@ func templateMainTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/main.tmpl", size: 647, mode: os.FileMode(420), modTime: time.Unix(1566131522, 0)} + info := bindataFileInfo{name: "template/main.tmpl", size: 647, mode: os.FileMode(420), modTime: time.Unix(1566138012, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x4b\x6f\xdb\x38\x10\x3e\x4b\xbf\x62\x6a\xa0\x81\x14\x78\xe5\x6e\x6f\xab\xc2\x87\xa2\x4d\x81\xec\x23\x5d\x34\xdd\xbd\x14\x45\x4b\x4b\x43\x9b\xad\x44\xaa\x24\xed\x34\x0d\xf2\xdf\x17\xc3\x87\x1e\xb6\x93\xdd\x6d\x91\x00\x81\xa5\x99\xf9\x86\x9c\x6f\x1e\xa4\x16\x0b\x78\xa1\xba\x6b\x2d\xd6\x1b\x0b\x4f\x9f\xfc\xfc\xcb\x4f\x9d\x46\x83\xd2\xc2\x2b\x56\xe1\x4a\xa9\xcf\x70\x2e\xab\x02\x9e\x37\x0d\x38\x23\x03\xa4\xd7\x3b\xac\x8b\x74\xb1\x80\xb7\x1b\x61\xc0\xa8\xad\xae\x10\x2a\x55\x23\x08\x03\x8d\xa8\x50\x1a\xac\x61\x2b\x6b\xd4\x60\x37\x08\xcf\x3b\x56\x6d\x10\x9e\x16\x4f\xa2\x16\xb8\xda\xca\x9a\x5c\x08\xe9\x4c\x7e\x3f\x7f\x71\x76\x71\x79\x06\x5c\x34\x18\x65\x5a\x29\x0b\xb5\xd0\x58\x59\xa5\xaf\x41\x71\xb0\xa3\xf5\xac\x46\x2c\xd2\xb4\x63\xd5\x67\xb6\x46\x68\x14\xab\xd3\x54\xb4\x9d\xd2\x16\xb2\x34\x99\xa1\xac\x54\x2d\xe4\x7a\xf1\xc9\x28\x39\x4b\x93\x19\x6f\x2d\xfd\x68\xe4\x0d\x56\x76\x96\xa6\xc9\x6c\x2d\xec\x66\xbb\x2a\x2a\xd5\x2e\x78\x08\x58\xc8\x6a\xbb\x62\x56\xe9\x05\x4a\xbb\x30\xd5\x06\x5b\xb6\xc0\x7a\x8d\xff\x09\x30\xfb\x1f\x4e\xb9\xc0\xa6\x9e\xa5\x79\x4a\x34\x5c\x3a\x19\x68\x0c\x09\x30\xc0\x24\xa0\xb4\x45\x50\xd8\x0d\xb3\x70\xc5\x8c\x8b\x13\x6b\xe0\x5a\xb5\xc0\xa0\x52\x6d\xd7\x08\x22\xdb\xa0\x86\xc0\x45\x91\xda\xeb\x0e\xa3\x4b\x63\xf5\xb6\xb2\x70\x93\x26\x17\xac\x45\x00\x20\x89\x90\x6b\x00\xf8\x48\xd4\x94\x33\xc9\x5a\x9c\xab\x56\x58\x6c\x3b\x7b\x3d\xfb\x98\x26\x67\xf5\x1a\x0d\x00\xbc\x7b\x7f\x4a\x8f\xbd\x25\xf1\x60\xa6\xa6\xaf\x28\x0a\xe3\x4c\xdd\x63\x34\x75\xd1\xed\xd9\x9e\xcb\x1a\xbf\xa2\x21\x5b\xf7\x18\x6d\x85\x97\x4f\x8c\x6f\x1d\x2d\xde\xe5\x21\x2b\x5e\xfe\x1d\xa4\x78\xe0\x21\x27\xfe\xaf\x67\xe6\x1e\x6e\xde\x92\x9b\xfe\xcf\x85\x59\x38\x59\x40\xd0\x32\x7b\x08\xb6\x86\xfb\xd6\xb0\x6c\x3d\x05\x5c\x8a\x6f\xa3\x25\x4e\x85\xb4\xe1\x31\x00\x8c\xf8\xb6\xb7\xc4\x8b\x0d\xd3\x06\xa3\xd9\xe9\xb0\x46\x40\x54\x5e\xbf\x07\x52\x4d\xc3\xac\x50\xf2\x2e\x50\xd4\x4f\x61\x7f\x49\xf1\x65\xdb\xef\x6f\xa5\x54\x33\xdd\xdd\xd6\xe9\xa7\x98\x0b\xd1\x34\x6c\xd5\xe0\x5d\x18\x19\xf4\x53\xd4\xeb\x8e\x56\x67\xcd\x5d\x28\x15\xf4\x53\xd4\x4b\xe4\x6c\xdb\xd8\x3b\xf7\x57\x7b\xfd\x5e\x50\x5d\xcd\x2c\x46\xe8\x91\xa0\x9c\xfe\xc3\x51\xec\x79\xdb\x6e\x6d\x1f\xdd\x21\x56\x44\xfd\x14\xf6\x37\x6b\x44\x4d\x43\x81\x3a\x0d\x86\x24\x47\xd8\xae\xd7\x1f\x69\x0c\xd7\x96\x87\x7d\xe1\xc4\xdf\xd1\x16\x0e\x77\xa4\x2b\x42\x4d\xfc\x7b\x33\x4c\x0d\xef\xe9\x81\x3d\xc3\xfd\xd2\x7f\x83\xdc\x2f\x3e\xb5\xd3\xc8\x3f\x1c\xae\xfe\x06\x79\x28\xf8\xc9\x94\xd2\xc8\xef\xa8\xd8\x90\x9b\x7b\x0a\xf5\x5c\xee\x50\x1b\xdc\x37\x15\x5e\xbc\xbf\xfc\x97\xad\xd0\x58\xef\xd9\xea\x20\x3e\x92\x35\x3f\xf5\x0e\xd3\xe6\xe5\xdf\x91\x37\x0f\x1c\x12\x17\x22\xed\x6b\xf0\x9e\x48\xc3\x8c\x7f\xf7\x7e\xca\xf4\xdd\x23\x7e\xdf\xf2\xc8\x84\xf7\x51\x5e\xe0\x95\xcb\x47\xa5\x91\x59\x74\x41\x86\x88\xc8\xb9\x0f\xcb\x3d\xd5\x68\x2a\x2d\x3a\xab\x74\x91\xf2\xad\xac\x22\x32\xc3\x1a\x4e\xc9\xa2\x78\xd9\x5b\xe4\x21\xc9\x37\x69\x22\x11\xca\x25\x9c\xd0\xeb\x4d\x9a\x50\x69\x95\xbe\x0c\xb0\x2e\xde\xb2\xf5\x9c\x64\xd7\x1d\x96\xbd\x8c\xaa\x31\x4d\x5c\x55\xf7\x42\x7a\x21\xa1\x67\xac\xf4\x42\xff\x42\xe2\x50\x07\xa5\x13\x87\x17\x92\xc7\x9c\x97\x24\x8f\x2f\x5e\xc1\x83\x7f\xa7\xe0\xc1\xff\x6d\x9a\x08\x0e\x1a\x39\x6d\xd9\x6b\x9e\xb9\xd7\x47\x4b\x90\xa2\xa1\x70\x12\x89\x24\x86\x65\x1f\xbe\x46\x9e\x3b\xa8\x46\xbb\xd5\x12\x24\x06\x66\xff\x60\xda\x6c\x58\x13\x4e\x76\x77\xc3\x41\x77\x55\x1a\xdd\x14\x84\xb4\xa8\xe9\xe2\x41\x4f\x0a\x18\xfc\x7a\xf9\xfa\x82\xc0\xae\xbc\x2a\x26\x61\x45\xcc\x13\xb4\xf6\x26\xe4\x20\x80\xd5\xea\x13\x56\x36\xfc\x84\xa4\x4c\x16\xcd\x4c\x5c\x9b\xaa\x36\xac\x94\x43\xb6\x82\x77\xef\x57\xd7\x16\xe7\x80\x5a\xd3\x3f\x65\xec\x26\x4d\x8c\x4b\x95\xc7\xde\x78\x82\x84\xf4\x77\xba\x2c\xdc\xc4\x5c\x7e\x5e\xf3\xe0\x39\xcf\x5d\x6a\xb2\xfc\x36\x4d\x42\x85\x39\x97\xe5\x12\x0c\xe3\xe8\x6b\x31\xda\x3a\x72\x49\x3b\x62\x33\x72\x26\x9a\x39\xf0\xd6\x16\x67\xb4\x17\x9e\xcd\xc2\xc6\x1f\x7f\x29\xe1\xf1\x6e\x36\x07\xe3\x4b\x80\xe0\x9e\x6c\xae\x34\x7c\x98\x83\xcb\x94\x66\x92\x2a\xd5\x17\x3e\x79\xe5\x35\x89\xf9\xa8\x20\xb3\x3c\x4d\x12\xe3\xac\x4f\xdc\xae\xc8\x6c\x54\x63\xfe\x7a\x30\x14\xda\xa8\x26\xa3\x2a\x16\xe6\xa8\x84\x7b\x95\xaf\xe3\x51\x79\x46\xcd\x50\xa3\xfd\xa9\x5a\x0e\x8b\xc5\x73\x94\xd4\xf1\xf8\x1c\xd4\x51\xe2\xd4\xfd\xb1\x55\x46\x75\x2f\x71\xfa\xe1\x7c\x72\x06\x0d\xca\x8c\xd7\xc5\x20\xcd\x9d\x55\x38\x32\xcb\x61\x83\xf1\x10\xf5\x39\xf1\x51\x8c\x4f\xd7\xd2\x45\x31\x39\x6f\x07\xd3\xdb\x34\xa1\x9c\xf2\xba\x70\x97\xa0\x47\x4b\x78\xe2\xf8\x4f\x0c\xf7\x92\x25\x9c\x04\xe5\xc4\x3a\x5e\x80\x1e\x2d\x61\x36\xeb\x11\x51\xea\x41\xe1\x6d\x8a\xeb\xef\x40\x7b\xc8\x5e\x1e\xb0\xf1\x3d\xa0\x4d\x11\xa6\xe2\x12\x58\xd7\xa1\xac\xb3\x28\x99\x83\x09\xdd\xeb\x47\xe9\xb8\x7a\xdd\xcc\x7d\xc8\xe2\xc5\xa1\x78\xdd\xea\xce\xa9\x29\xfc\xac\x1f\x6d\xf5\xcc\x6f\xad\x9f\xb7\x93\xba\xce\xbd\xcb\x78\x2b\x1f\x07\x10\x6e\xf0\x0f\x19\x82\xa8\xbf\x0e\x41\x84\x3d\x38\xc7\x41\x21\xea\xaf\x07\x5d\x58\xc4\x2f\x8b\x51\x88\xe7\x71\xfb\x27\xee\xc9\x25\xd6\x85\x5d\x82\xf3\xe1\x29\x20\xa9\xcf\x5b\xe9\xa4\x21\x87\xe3\xd6\x23\xf1\xd0\x74\xb7\x93\xc9\x4c\x27\x61\x11\x06\x64\x66\xf2\x30\xa6\x87\x41\x05\x57\x9a\x75\xc6\x4d\x58\x1f\x7f\x2c\x9b\x16\xed\x46\xd5\x70\x25\xec\x06\x34\x56\x6a\x47\x9f\xca\x0a\x50\x9a\xad\x46\x90\x0a\x3a\x26\x45\x65\xe8\x53\xb8\xf5\xee\x85\x5c\x87\x81\x7c\x30\x07\x0f\xa6\x31\x8f\x27\x76\xff\xad\xb4\x3f\x97\x6b\xe4\xa8\x81\xdc\x65\xb9\x67\x97\xc3\xce\xf1\xee\x37\x93\xe5\xcf\x60\x37\x4e\x6b\x42\xf8\xe5\x91\x8c\xc6\x88\xfc\x86\x43\x72\x77\x94\x96\x30\xbf\xc1\x39\xf1\x7d\x73\x4b\xf9\x0a\xdc\x4d\xe0\x59\x3e\x77\x56\x03\x81\xbe\x66\x0f\xf8\xf3\xe2\x1f\xa5\x6f\xdc\x88\x07\xec\xf9\xce\xf1\xe4\x91\xe1\x03\x72\xe7\xa3\x39\x42\x1d\x86\x8e\xbd\x8f\x39\x1f\xc4\x01\x71\xb1\x17\x0e\xa8\x8b\x8a\x1f\x25\x6f\x3a\x04\x0e\xe8\x13\xfd\x57\x7e\x7f\xb5\x7d\x40\x06\x63\x50\x47\x38\x14\xfd\x50\xb8\x8f\xc5\x18\xcd\xc0\xa3\x0b\xb4\xbf\xa5\x58\x18\xdf\x53\xf2\xc9\x1b\xed\x8d\xc6\x96\x2d\x7e\x13\xb2\xce\x72\x58\x2e\x7b\xfd\x9f\x56\xbb\xad\xd3\xe9\x63\x8b\xb3\x06\xdb\x6c\x32\x3a\x6c\x7a\x9b\xfe\x13\x00\x00\xff\xff\x2b\xd1\x21\x50\x80\x13\x00\x00") +var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\xdb\x6e\xdb\x3c\x12\xbe\x96\x9e\x62\x6a\xa0\x81\x54\x78\xe5\x6e\xef\xd6\x85\x2f\x8a\x36\x05\xb2\x87\x74\xd1\x74\xf7\xa6\x28\x5a\x5a\x1c\xda\x6c\x25\x52\x25\x69\xa7\x69\x90\x77\x5f\x0c\x0f\x3a\xd8\x4e\xf6\xff\x5b\x24\x40\x60\x69\x4e\xe4\x7c\xf3\x71\x86\x5a\x2c\xe0\xb5\xee\x6e\x8c\xdc\x6c\x1d\xbc\x78\xfe\xd7\xbf\xfd\xa5\x33\x68\x51\x39\x78\xcb\x6a\x5c\x6b\xfd\x0d\x2e\x54\x5d\xc1\xab\xa6\x01\x6f\x64\x81\xf4\x66\x8f\xbc\xca\x17\x0b\xf8\xb0\x95\x16\xac\xde\x99\x1a\xa1\xd6\x1c\x41\x5a\x68\x64\x8d\xca\x22\x87\x9d\xe2\x68\xc0\x6d\x11\x5e\x75\xac\xde\x22\xbc\xa8\x9e\x27\x2d\x08\xbd\x53\x9c\x42\x48\xe5\x4d\xfe\x79\xf1\xfa\xfc\xf2\xea\x1c\x84\x6c\x30\xc9\x8c\xd6\x0e\xb8\x34\x58\x3b\x6d\x6e\x40\x0b\x70\xa3\xf5\x9c\x41\xac\xf2\xbc\x63\xf5\x37\xb6\x41\x68\x34\xe3\x79\x2e\xdb\x4e\x1b\x07\x45\x9e\xcd\x50\xd5\x9a\x4b\xb5\x59\x7c\xb5\x5a\xcd\xf2\x6c\x26\x5a\x47\x3f\x06\x45\x83\xb5\x9b\xe5\x79\x36\xdb\x48\xb7\xdd\xad\xab\x5a\xb7\x0b\x11\x13\x96\xaa\xde\xad\x99\xd3\x66\x81\xca\x2d\x6c\xbd\xc5\x96\x2d\x90\x6f\xf0\x0f\x39\xcc\xfe\x44\x50\x21\xb1\xe1\xb3\xbc\xcc\x09\x86\x2b\x2f\x03\x83\xb1\x00\x16\x98\x02\x54\xae\x8a\x0a\xb7\x65\x0e\xae\x99\xf5\x79\x22\x07\x61\x74\x0b\x0c\x6a\xdd\x76\x8d\x24\xb0\x2d\x1a\x88\x58\x54\xb9\xbb\xe9\x30\x85\xb4\xce\xec\x6a\x07\xb7\x79\x76\xc9\x5a\x04\x00\x92\x48\xb5\x01\x80\x2f\x04\xcd\x72\xa6\x58\x8b\x73\xdd\x4a\x87\x6d\xe7\x6e\x66\x5f\xf2\xec\x9c\x6f\xd0\x02\xc0\xc7\x4f\xcf\xe8\xb1\xb7\x24\x1c\xec\xd4\xf4\x2d\x65\x61\xbd\xa9\x7f\x4c\xa6\x3e\xbb\x03\xdb\x0b\xc5\xf1\x07\x5a\xb2\xf5\x8f\xc9\x56\x06\xf9\xc4\xf8\xce\xc3\x12\x42\x1e\xa3\x12\xe4\xbf\x00\x4a\x70\x3c\xc6\x24\xfc\xf5\xc8\x3c\x80\xcd\x07\x0a\xd3\xff\xf9\x34\x2b\x2f\x8b\x1e\xb4\xcc\x81\x07\xdb\xc0\x43\x6b\x38\xb6\x99\x3a\x5c\xc9\x9f\xa3\x25\x9e\x49\xe5\xe2\x63\x74\xb0\xf2\xe7\xc1\x12\xff\x51\xf2\xfb\xae\xf7\x59\x6b\xdd\x4c\x3d\x76\x5e\x3f\xf5\xb9\x94\x4d\xc3\xd6\x0d\xde\xe7\xa3\xa2\x7e\xea\xf5\xae\x73\x52\x2b\xd6\xdc\xe7\xa5\xa3\x7e\xea\xf5\x06\x05\xdb\x35\xee\xde\xfd\xf1\xa0\x3f\x48\xaa\xe3\xcc\x61\x72\x3d\x91\x94\xd7\x7f\x3e\xe9\x7b\xd1\xb6\x3b\xd7\x67\x77\xec\x2b\x93\x7e\xea\xf6\x5f\xd6\x48\x4e\x07\x95\xd8\x0f\x03\xf0\xc9\x6d\xdf\xeb\x4f\x90\xd5\x1f\x95\x63\xae\x7a\xf1\x2f\x50\xd5\xfb\x9d\x60\x6a\x24\xd0\xff\x27\xe8\xd4\xf0\x01\x5e\x1e\x18\x1e\xd2\xf1\x3d\x8a\xb0\xf8\xd4\xce\xa0\xf8\x7c\xbc\xfa\x7b\x14\x91\xb6\x93\xce\x61\x50\xdc\xc3\xd8\x58\x9b\x07\x88\x7a\xa1\xf6\x68\x2c\x1e\x9a\xca\x20\x3e\x5c\xfe\xfb\x4e\x1a\xe4\x07\xb6\x26\x8a\x4f\x54\x2d\x74\xa2\xe3\xb2\x05\xf9\x2f\xd4\x2d\x38\x0e\x85\x8b\x99\xf6\x1c\x7c\x20\xd3\xd8\x77\x3f\x7e\x9a\x22\x7d\x7f\xdb\x3d\xb4\x3c\xd1\x75\x43\x96\x97\x78\xed\xeb\x51\x1b\x64\x0e\x7d\x92\x31\x23\x0a\x1e\xd2\xf2\x4f\x1c\x6d\x6d\x64\xe7\xb4\xa9\x72\xb1\x53\x75\xf2\x2c\x90\xc3\x33\xb2\xa8\xde\xf4\x16\x65\x2c\xf2\x6d\x9e\x29\x84\xe5\x0a\xce\xe8\xf5\x36\xcf\x88\x5a\xcb\x40\x03\xe4\xd5\x07\xb6\x99\x93\xec\xa6\xc3\x65\x2f\x23\x36\xe6\x99\x67\x75\x2f\xa4\x17\x12\x06\xc4\x96\x41\x18\x5e\x48\x1c\x79\xb0\xf4\xe2\xf8\x42\xf2\x54\xf3\x25\xc9\xd3\x4b\x50\x88\x18\xdf\x2b\x44\x8c\x7f\x97\x67\x52\x80\x41\x41\x5b\x0e\x9a\x97\xfe\xf5\xc9\x0a\x94\x6c\x28\x9d\x4c\x21\x89\x61\xd5\xa7\x6f\x50\x94\xde\xd5\xa0\xdb\x19\x05\x0a\x23\xb2\xff\x62\xc6\x6e\x59\x13\xa7\xad\xbf\x75\xa0\xbf\xbe\x8c\xa6\xb7\x54\x0e\x0d\x5d\x06\xe8\x49\x03\x83\xbf\x5f\xbd\xbb\x24\x67\x4f\xaf\x9a\x29\x58\x13\xf2\xe4\xca\x83\x09\x05\x88\xce\x7a\xfd\x15\x6b\x17\x7f\x62\x51\x26\x8b\x16\x36\xad\x4d\xac\x8d\x2b\x95\x50\xac\xe1\xe3\xa7\xf5\x8d\xc3\x39\xa0\x31\xf4\x4f\x15\xbb\xcd\x33\xeb\x4b\x15\x7c\x6f\x03\x40\x52\x85\x7b\x56\x11\x6f\x47\xbe\x3e\xef\x44\x8c\x5c\x96\xbe\x34\x45\x79\x97\x67\x91\x61\x3e\xe4\x72\x05\x96\x09\x0c\x5c\x4c\xb6\x1e\x5c\xd2\x8e\xd0\x4c\x98\xc9\x66\x0e\xa2\x75\xd5\x39\xed\x45\x14\xb3\xb8\xf1\xa7\xdf\x97\xf0\x74\x3f\x9b\x83\x0d\x14\x20\xf7\x00\xb6\xd0\x06\x3e\xcf\xc1\x57\xca\x30\x45\x4c\x0d\xc4\xa7\xa8\x82\x93\x58\x8c\x08\x59\x94\x79\x96\x59\x6f\x7d\xe6\x77\x45\x66\x23\x8e\x85\x91\x3d\x10\x6d\xc4\xc9\xa4\x4a\xc4\x1c\x51\xb8\x57\x05\x1e\x8f\xe8\x99\x34\x03\x47\xfb\xa9\xba\x1c\x16\x4b\x73\x94\xd4\x69\x7c\x0e\xea\x24\xf1\xea\x7e\x6c\x2d\x93\xba\x97\x78\xfd\x30\x9f\xbc\x41\x83\xaa\x10\xbc\x1a\xa4\xa5\xb7\x8a\x23\x73\x39\x6c\x30\x0d\xd1\x50\x93\x90\xc5\x78\xba\x2e\x7d\x16\x93\x79\x3b\x98\xde\xe5\x19\xd5\x54\xf0\xca\x5f\x4c\x9e\xac\xe0\xb9\xc7\x3f\xb3\x22\x48\x56\x70\x16\x95\xd1\xda\x56\xb1\x3f\xad\x80\x75\x1d\x2a\x5e\x24\xc9\x1c\x6c\x3c\x47\xa1\xa9\x8d\x79\xe4\xbb\xdf\x63\xd2\x08\x07\x1a\xf9\xd5\x7d\x50\x5b\x85\xae\x3b\xda\xea\x79\xd8\x5a\xdf\xf9\x26\x0c\x2b\x43\xc8\x74\x67\x1d\x27\x10\xef\xb7\x8f\x99\x82\xe4\x3f\x86\x24\xe2\x1e\x7c\xe0\xa8\x90\xfc\xc7\xd1\x79\xa8\xd2\xbd\x7b\x94\xe2\x45\xda\xfe\x99\x7f\xf2\xe5\xf4\x69\x2f\xc1\xc7\x08\x10\x90\x34\xd4\x6d\xe9\xa5\xb1\x86\xe3\x43\x40\xe2\x81\xfe\x77\x93\x1e\x49\x33\xa9\x8a\xad\xaa\xb0\x65\x6c\x98\x43\xcb\x80\x6b\xc3\x3a\xeb\x7b\x5d\xc8\x3f\xd1\xa6\x45\xb7\xd5\x1c\xae\xa5\xdb\x82\xc1\x5a\xef\xe9\x43\x52\x03\x2a\xbb\x33\x08\x4a\x43\xc7\x94\xac\x2d\x7d\x28\xb6\x21\xbc\x54\x9b\xd8\x1a\x8f\x3a\xd2\x51\x5f\x14\x69\x76\xf6\x5f\x12\x87\x1d\x92\xa3\x40\x03\x14\xae\x28\x03\xba\x02\xf6\x1e\xf7\xb0\x99\xa2\x7c\x09\xfb\x71\x59\x33\xf2\x5f\x9d\xa8\x68\xca\x28\x6c\x38\x16\x77\x4f\x65\x89\x9d\x14\x7c\x90\x70\x6e\xee\xa8\x5e\x11\xbb\x89\x7b\x51\xce\xbd\xd5\x00\x60\xe0\xec\x11\x7e\x41\xfc\xbb\xf0\x8d\x0f\xe2\x11\x7a\xe1\xe4\x04\xf0\xc8\xf0\x11\xb1\x0b\xd9\x9c\x80\x0e\xe3\x89\x7d\x08\xb9\x90\xc4\x11\x70\xe9\x2c\x1c\x41\x97\x14\xbf\x0b\xde\xb4\x09\x1c\xc1\x27\xfb\x6f\xe0\xfe\x92\xf9\x88\x08\xa6\xa4\x4e\x60\x28\xfb\xa6\xf0\x10\x8a\x29\x9b\x01\x47\x9f\x68\x7f\x5f\x70\x30\xbe\x31\x94\x93\x37\xda\x1b\xb5\x2d\x57\xfd\x43\x2a\x5e\x94\xb0\x5a\xf5\xfa\x7f\x3b\xe3\xb7\xee\x60\x05\xae\x3a\x6f\xb0\x2d\x26\xad\xc3\xe5\x77\xf9\xff\x02\x00\x00\xff\xff\x63\x87\x08\x63\x9e\x12\x00\x00") func schemaGoBytes() ([]byte, error) { return bindataRead( @@ -102,7 +113,7 @@ func schemaGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "schema.go", size: 4992, mode: os.FileMode(420), modTime: time.Unix(1566995215, 0)} + info := bindataFileInfo{name: "schema.go", size: 4766, mode: os.FileMode(420), modTime: time.Unix(1567076814, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/load/schema.go b/entc/load/schema.go index d8c90c13e..497c14ab6 100644 --- a/entc/load/schema.go +++ b/entc/load/schema.go @@ -29,8 +29,6 @@ type Field struct { Type field.Type `json:"type,omitempty"` Tag string `json:"tag,omitempty"` Size *int `json:"size,omitempty"` - Charset *string `json:"charset,omitempty"` - Collation *string `json:"collation,omitempty"` Unique bool `json:"unique,omitempty"` Nillable bool `json:"nillable,omitempty"` Optional bool `json:"optional,omitempty"` @@ -101,12 +99,6 @@ func MarshalSchema(schema ent.Interface) (b []byte, err error) { if fd.Size != 0 { sf.Size = &fd.Size } - if fd.Charset != "" { - sf.Charset = &fd.Charset - } - if fd.Collation != "" { - sf.Collation = &fd.Collation - } s.Fields = append(s.Fields, sf) } edges, err := safeEdges(schema) diff --git a/schema/field/field.go b/schema/field/field.go index bd911e3ed..f285754d6 100644 --- a/schema/field/field.go +++ b/schema/field/field.go @@ -117,8 +117,6 @@ type Descriptor struct { Size int // varchar size. Name string // field name. Type Type // field type. - Charset string // string charset. - Collation string // string collation. Unique bool // unique index of field. Nillable bool // nillable struct field. Optional bool // nullable field in database. @@ -245,20 +243,6 @@ func (b *stringBuilder) StructTag(s string) *stringBuilder { return b } -// Charset sets the character set attribute for character fields. -// For example, utf8 or utf8mb4 in MySQL. -func (b *stringBuilder) Charset(s string) *stringBuilder { - b.desc.Charset = s - return b -} - -// Collation sets the collation attribute for character fields. -// For example, utf8_general_ci or utf8mb4_bin in MySQL. -func (b *stringBuilder) Collation(c string) *stringBuilder { - b.desc.Collation = c - return b -} - // Descriptor implements the ent.Field interface by returning its descriptor. func (b *stringBuilder) Descriptor() *Descriptor { return b.desc diff --git a/schema/field/field_test.go b/schema/field/field_test.go index 8a5c72278..f9bdbd3a5 100644 --- a/schema/field/field_test.go +++ b/schema/field/field_test.go @@ -81,20 +81,6 @@ func TestString(t *testing.T) { assert.Len(t, fd.Validators, 2) } -func TestCharset(t *testing.T) { - fd := field.String("name"). - Charset("utf8"). - Descriptor() - assert.Equal(t, "utf8", fd.Charset) -} - -func TestCollation(t *testing.T) { - fd := field.String("name"). - Collation("utf8_general_ci"). - Descriptor() - assert.Equal(t, "utf8_general_ci", fd.Collation) -} - func TestTime(t *testing.T) { now := time.Now() fd := field.Time("created_at").