fb-2036 improve coverage for create view statement (#2333)

This commit is contained in:
Vengata Krishnan 2023-03-21 14:06:38 -04:00 • committed by GitHub
parent 0e70d80030
commit 2cf972b5d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View file

@ -594,7 +594,7 @@ func NewErrTableOrViewNotFound(line, col int, tableName string) error {
func NewErrTableExists(line, col int, tableName string) error {
return errors.New(
ErrTableExists,
fmt.Sprintf("[%d:%d] table '%s' already exists", line, col, tableName),
fmt.Sprintf("[%d:%d] table or view '%s' already exists", line, col, tableName),
)
}

View file

@ -96,7 +96,7 @@ func (i *createViewIter) Next(ctx context.Context) (types.Row, error) {
if i.ifNotExists {
return nil, types.ErrNoMoreRows
}
return nil, sql3.NewErrViewExists(0, 0, i.view.name)
return nil, sql3.NewErrTableExists(0, 0, i.view.name)
}
// now check in the views table to see if it is exists

View file

@ -691,7 +691,7 @@ func TestPlanner_CreateTable(t *testing.T) {
if err == nil {
t.Fatal("expected error")
} else {
if err.Error() != "[0:0] table 'allcoltypes' already exists" {
if err.Error() != "[0:0] table or view 'allcoltypes' already exists" {
t.Fatal(err)
}
}

View file

@ -21,6 +21,14 @@ var viewTests = TableTest{
),
),
SQLTests: []SQLTest{
// test for error where an table exist with the requested new view name.
{
name: "create-view-should-fail",
SQLs: sqls(
"create view viewtable as select _id, a_string, a_int from viewtable;",
),
ExpErr: "table or view 'viewtable' already exists",
},
{
name: "create-view",
SQLs: sqls(