Skip to content

Commit

Permalink
fix: record comments for drop index and alter database, change commen…
Browse files Browse the repository at this point in the history
…ts position in create database

Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Sep 13, 2024
1 parent 035ef96 commit 698a52a
Show file tree
Hide file tree
Showing 12 changed files with 6,321 additions and 6,334 deletions.
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ type (

// AlterDatabase represents a ALTER database statement.
AlterDatabase struct {
Comments *ParsedComments
DBName IdentifierCS
UpdateDataDirectory bool
AlterOptions []DatabaseOption
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion go/vt/sqlparser/ast_copy_on_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_equals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ func (node *SelectInto) Format(buf *TrackedBuffer) {

// Format formats the node.
func (node *CreateDatabase) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "create database %v", node.Comments)
buf.astPrintf(node, "create %vdatabase ", node.Comments)
if node.IfNotExists {
buf.literal("if not exists ")
}
Expand All @@ -2205,7 +2205,7 @@ func (node *CreateDatabase) Format(buf *TrackedBuffer) {

// Format formats the node.
func (node *AlterDatabase) Format(buf *TrackedBuffer) {
buf.literal("alter database")
buf.astPrintf(node, "alter %vdatabase", node.Comments)
if node.DBName.NotEmpty() {
buf.astPrintf(node, " %v", node.DBName)
}
Expand Down
7 changes: 5 additions & 2 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go/vt/sqlparser/ast_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_visit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions go/vt/sqlparser/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2803,12 +2803,12 @@ var (
}, {
input: "rollback",
}, {
input: "create database /* simple */ test_db",
input: "create /* simple */ database test_db",
}, {
input: "create schema test_db",
output: "create database test_db",
}, {
input: "create database /* simple */ if not exists test_db",
input: "create /* simple */ database if not exists test_db",
}, {
input: "create schema if not exists test_db",
output: "create database if not exists test_db",
Expand Down
Loading

0 comments on commit 698a52a

Please sign in to comment.