dialect/sql/schema: skip default value parsing on pg functions (#951)

Closes #934
This commit is contained in:
Ariel Mashraki
2020-11-15 22:55:52 +02:00
committed by GitHub
parent d5b69da9e0
commit 77eaad0df6
2 changed files with 37 additions and 1 deletions

View File

@@ -175,6 +175,32 @@ func TestPostgres_Create(t *testing.T) {
mock.ExpectCommit()
},
},
{
name: "scan table with default set to serial",
tables: []*Table{
{
Name: "users",
Columns: []*Column{
{Name: "id", Type: field.TypeInt, Increment: true},
},
PrimaryKey: []*Column{
{Name: "id", Type: field.TypeInt, Increment: true},
},
},
},
before: func(mock pgMock) {
mock.start("120000")
mock.tableExists("users", true)
mock.ExpectQuery(escape(`SELECT "column_name", "data_type", "is_nullable", "column_default" FROM INFORMATION_SCHEMA.COLUMNS WHERE "table_schema" = CURRENT_SCHEMA() AND "table_name" = $1`)).
WithArgs("users").
WillReturnRows(sqlmock.NewRows([]string{"column_name", "data_type", "is_nullable", "column_default"}).
AddRow("id", "bigint", "NO", "nextval('users_colname_seq'::regclass)"))
mock.ExpectQuery(escape(fmt.Sprintf(indexesQuery, "users"))).
WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "primary", "unique", "seq_in_index"}).
AddRow("users_pkey", "id", "t", "t", 0))
mock.ExpectCommit()
},
},
{
name: "add column to table",
tables: []*Table{