Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var (
grantRe = regexp.MustCompile(`(?is)^GRANT\s.+$`)
revokeRe = regexp.MustCompile(`(?is)^REVOKE\s.+$`)
alterRe = regexp.MustCompile(`(?is)^ALTER\s.+$`)
renameRe = regexp.MustCompile(`(?is)^RENAME\s.+$`)
truncateTableRe = regexp.MustCompile(`(?is)^TRUNCATE\s+TABLE\s+(.+)$`)
analyzeRe = regexp.MustCompile(`(?is)^ANALYZE$`)

Expand Down Expand Up @@ -150,6 +151,8 @@ func BuildStatementWithComments(stripped, raw string) (Statement, error) {
return &DdlStatement{Ddl: stripped}, nil
case alterRe.MatchString(stripped):
return &DdlStatement{Ddl: stripped}, nil
case renameRe.MatchString(stripped):
return &DdlStatement{Ddl: stripped}, nil
case grantRe.MatchString(stripped):
return &DdlStatement{Ddl: stripped}, nil
case revokeRe.MatchString(stripped):
Expand Down
5 changes: 5 additions & 0 deletions statement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func TestBuildStatement(t *testing.T) {
input: "CREATE TABLE t1 (id INT64 NOT NULL) PRIMARY KEY (id)",
want: &DdlStatement{Ddl: "CREATE TABLE t1 (id INT64 NOT NULL) PRIMARY KEY (id)"},
},
{
desc: "RENAME TABLE statement",
input: "RENAME TABLE t1 TO t2, t3 TO t4",
want: &DdlStatement{Ddl: "RENAME TABLE t1 TO t2, t3 TO t4"},
},
{
desc: "ALTER TABLE statement",
input: "ALTER TABLE t1 ADD COLUMN name STRING(16) NOT NULL",
Expand Down