Skip to content

Commit de17e98

Browse files
committed
Fixed regression test failures
1 parent 0c5ecbf commit de17e98

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

server/hook/rename_table.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ func AfterTableRename(ctx *sql.Context, runner sql.StatementRunner, nodeInterfac
3838
// Grab the table being altered (so we know the schema)
3939
sqlTable, ok := n.TableExists(ctx, n.NewNames[0])
4040
if !ok {
41-
return errors.New("RENAME TABLE post-hook did not receive a new table name")
41+
// Views do not manifest as tables, so we'll return here if this isn't a table
42+
return nil
4243
}
4344
doltTable := core.SQLTableToDoltTable(sqlTable)
4445
if doltTable == nil {

testing/go/alter_table_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,5 +964,34 @@ func TestAlterTable(t *testing.T) {
964964
},
965965
},
966966
},
967+
{
968+
Name: "ALTER TABLE RENAME on view",
969+
SetUpScript: []string{
970+
`CREATE TABLE tenk1 (
971+
unique1 int4,
972+
unique2 int4,
973+
two int4,
974+
four int4,
975+
ten int4,
976+
twenty int4,
977+
hundred int4,
978+
thousand int4,
979+
twothousand int4,
980+
fivethous int4,
981+
tenthous int4,
982+
odd int4,
983+
even int4,
984+
stringu1 name,
985+
stringu2 name,
986+
string4 name);`,
987+
`CREATE VIEW attmp_view (unique1) AS SELECT unique1 FROM tenk1;`,
988+
},
989+
Assertions: []ScriptTestAssertion{
990+
{
991+
Query: `ALTER TABLE attmp_view RENAME TO attmp_view_new;`,
992+
Expected: []sql.Row{},
993+
},
994+
},
995+
},
967996
})
968997
}

0 commit comments

Comments
 (0)