mirror of
https://github.com/ent/ent.git
synced 2026-05-05 17:10:54 +03:00
dialect/sql/schema: postgres support for uuid type
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/178 Reviewed By: alexsn Differential Revision: D18615561 fbshipit-source-id: 8244189186bf35d78cfdb991ee4f8cecd6411cee
This commit is contained in:
committed by
Facebook Github Bot
parent
33d08673cf
commit
db7b05ad04
@@ -56,6 +56,7 @@ func TestPostgres_Create(t *testing.T) {
|
||||
{Name: "age", Type: field.TypeInt},
|
||||
{Name: "doc", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "enums", Type: field.TypeEnum, Enums: []string{"a", "b"}},
|
||||
{Name: "uuid", Type: field.TypeUUID},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -66,7 +67,7 @@ func TestPostgres_Create(t *testing.T) {
|
||||
mock.ExpectQuery(escape(`SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE "table_schema" = CURRENT_SCHEMA() AND "table_name" = $1`)).
|
||||
WithArgs("users").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(0))
|
||||
mock.ExpectExec(escape(`CREATE TABLE IF NOT EXISTS "users"("id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL, "name" varchar NULL, "age" bigint NOT NULL, "doc" jsonb NULL, "enums" varchar NOT NULL, PRIMARY KEY("id"))`)).
|
||||
mock.ExpectExec(escape(`CREATE TABLE IF NOT EXISTS "users"("id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL, "name" varchar NULL, "age" bigint NOT NULL, "doc" jsonb NULL, "enums" varchar NOT NULL, "uuid" uuid NOT NULL, PRIMARY KEY("id"))`)).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
mock.ExpectCommit()
|
||||
},
|
||||
@@ -137,6 +138,7 @@ func TestPostgres_Create(t *testing.T) {
|
||||
Columns: []*Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "uuid", Type: field.TypeUUID, Nullable: true},
|
||||
{Name: "text", Type: field.TypeString, Nullable: true, Size: math.MaxInt32},
|
||||
{Name: "age", Type: field.TypeInt},
|
||||
},
|
||||
@@ -157,6 +159,7 @@ func TestPostgres_Create(t *testing.T) {
|
||||
WillReturnRows(sqlmock.NewRows([]string{"column_name", "data_type", "is_nullable", "column_default"}).
|
||||
AddRow("id", "bigint", "NO", "NULL").
|
||||
AddRow("name", "character varying", "YES", "NULL").
|
||||
AddRow("uuid", "uuid", "YES", "NULL").
|
||||
AddRow("text", "text", "YES", "NULL"))
|
||||
mock.ExpectQuery(escape(fmt.Sprintf(indexesQuery, "users"))).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "primary", "unique"}).
|
||||
|
||||
Reference in New Issue
Block a user