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
20 changes: 20 additions & 0 deletions normalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,17 @@ multiline comment */
Size: 7,
},
},
{
input: "VACUUM ANALYZE my_table",
expected: "VACUUM ANALYZE my_table",
statementMetadata: StatementMetadata{
Tables: []string{},
Comments: []string{},
Commands: []string{"VACUUM"},
Procedures: []string{},
Size: 6,
},
},
}

normalizer := NewNormalizer(
Expand Down Expand Up @@ -524,6 +535,15 @@ func TestNormalizerFormatting(t *testing.T) {
expected: "SELECT * FROM discount WHERE description LIKE ?",
uppercaseKeywords: true,
},
{
queries: []string{
"vacuum analyze my_table",
"VACUUM ANALYZE my_table",
"Vacuum Analyze my_table",
},
expected: "VACUUM ANALYZE my_table",
uppercaseKeywords: true,
},
}

for _, test := range tests {
Expand Down
22 changes: 22 additions & 0 deletions sqllexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,28 @@ here */`,
{IDENT, "test"},
},
},
{
name: "VACUUM should be classified as COMMAND",
input: "VACUUM ANALYZE my_table",
expected: []TokenSpec{
{COMMAND, "VACUUM"},
{SPACE, " "},
{KEYWORD, "ANALYZE"},
{SPACE, " "},
{IDENT, "my_table"},
},
},
{
name: "vacuum lowercase should be classified as COMMAND",
input: "vacuum analyze my_table",
expected: []TokenSpec{
{COMMAND, "vacuum"},
{SPACE, " "},
{KEYWORD, "analyze"},
{SPACE, " "},
{IDENT, "my_table"},
},
},
}

for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion sqllexer_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var commands = []string{
"STRAIGHT_JOIN",
"USE",
"CLONE",
"VACUUM",
}

var tableIndicatorCommands = []string{
Expand Down Expand Up @@ -135,7 +136,6 @@ var keywords = []string{
"ROLLUP",
"LITERAL",
"WINDOW",
"VACCUM",
"ANALYZE",
"ILIKE",
"USING",
Expand Down
Loading