Skip to content

Commit 3166a94

Browse files
author
AJ Roetker (aider)
committed
test: Add tests for DROP INDEX statements
1 parent fe77212 commit 3166a94

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

rel/parse_sql_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,28 @@ func TestSqlDrop(t *testing.T) {
747747
assert.Equal(t, lex.TokenDrop, ds.Keyword(), "Has keyword DROP")
748748
assert.Equal(t, "TABLE", ds.Tok.V, "Wanted TABLE: got %q", ds.Tok.V)
749749
assert.Equal(t, "articles", ds.Identity, "has articles: %v", ds.Identity)
750+
751+
sql = `DROP INDEX idx_user_email;`
752+
req, err = rel.ParseSql(sql)
753+
assert.Equal(t, nil, err)
754+
assert.NotEqual(t, nil, req)
755+
ds, ok = req.(*rel.SqlDrop)
756+
assert.True(t, ok, "wanted SqlDrop got %T", req)
757+
assert.Equal(t, lex.TokenDrop, ds.Keyword(), "Has keyword DROP")
758+
assert.Equal(t, "INDEX", ds.Tok.V, "Wanted INDEX: got %q", ds.Tok.V)
759+
assert.Equal(t, "idx_user_email", ds.Identity, "has idx_user_email: %v", ds.Identity)
760+
761+
sql = `DROP INDEX IF EXISTS idx_user_name ON users;`
762+
req, err = rel.ParseSql(sql)
763+
assert.Equal(t, nil, err)
764+
assert.NotEqual(t, nil, req)
765+
ds, ok = req.(*rel.SqlDrop)
766+
assert.True(t, ok, "wanted SqlDrop got %T", req)
767+
assert.Equal(t, lex.TokenDrop, ds.Keyword(), "Has keyword DROP")
768+
assert.Equal(t, "INDEX", ds.Tok.V, "Wanted INDEX: got %q", ds.Tok.V)
769+
assert.Equal(t, "idx_user_name", ds.Identity, "has idx_user_name: %v", ds.Identity)
770+
assert.Equal(t, "users", ds.Table, "has table users: %v", ds.Table)
771+
assert.True(t, ds.IfExists, "Expected IfExists to be true")
750772
}
751773

752774
func TestWithNameValue(t *testing.T) {

0 commit comments

Comments
 (0)