@@ -22,6 +22,7 @@ func TestParseAlterStatement(t *testing.T) {
22
22
parser := NewAlterTableParser ()
23
23
err := parser .ParseAlterStatement (statement )
24
24
test .S (t ).ExpectNil (err )
25
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , statement )
25
26
test .S (t ).ExpectFalse (parser .HasNonTrivialRenames ())
26
27
}
27
28
@@ -30,6 +31,7 @@ func TestParseAlterStatementTrivialRename(t *testing.T) {
30
31
parser := NewAlterTableParser ()
31
32
err := parser .ParseAlterStatement (statement )
32
33
test .S (t ).ExpectNil (err )
34
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , statement )
33
35
test .S (t ).ExpectFalse (parser .HasNonTrivialRenames ())
34
36
test .S (t ).ExpectEquals (len (parser .columnRenameMap ), 1 )
35
37
test .S (t ).ExpectEquals (parser .columnRenameMap ["ts" ], "ts" )
@@ -40,6 +42,7 @@ func TestParseAlterStatementTrivialRenames(t *testing.T) {
40
42
parser := NewAlterTableParser ()
41
43
err := parser .ParseAlterStatement (statement )
42
44
test .S (t ).ExpectNil (err )
45
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , statement )
43
46
test .S (t ).ExpectFalse (parser .HasNonTrivialRenames ())
44
47
test .S (t ).ExpectEquals (len (parser .columnRenameMap ), 2 )
45
48
test .S (t ).ExpectEquals (parser .columnRenameMap ["ts" ], "ts" )
@@ -61,6 +64,7 @@ func TestParseAlterStatementNonTrivial(t *testing.T) {
61
64
parser := NewAlterTableParser ()
62
65
err := parser .ParseAlterStatement (statement )
63
66
test .S (t ).ExpectNil (err )
67
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , statement )
64
68
renames := parser .GetNonTrivialRenames ()
65
69
test .S (t ).ExpectEquals (len (renames ), 2 )
66
70
test .S (t ).ExpectEquals (renames ["i" ], "count" )
@@ -136,6 +140,7 @@ func TestParseAlterStatementDroppedColumns(t *testing.T) {
136
140
statement := "drop column b, drop key c_idx, drop column `d`"
137
141
err := parser .ParseAlterStatement (statement )
138
142
test .S (t ).ExpectNil (err )
143
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , statement )
139
144
test .S (t ).ExpectEquals (len (parser .droppedColumns ), 2 )
140
145
test .S (t ).ExpectTrue (parser .droppedColumns ["b" ])
141
146
test .S (t ).ExpectTrue (parser .droppedColumns ["d" ])
@@ -181,6 +186,7 @@ func TestParseAlterStatementRenameTable(t *testing.T) {
181
186
statement := "drop column b, rename as something_else"
182
187
err := parser .ParseAlterStatement (statement )
183
188
test .S (t ).ExpectNil (err )
189
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , statement )
184
190
test .S (t ).ExpectTrue (parser .isRenameTable )
185
191
}
186
192
{
@@ -208,6 +214,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
208
214
test .S (t ).ExpectNil (err )
209
215
test .S (t ).ExpectEquals (parser .explicitSchema , "" )
210
216
test .S (t ).ExpectEquals (parser .explicitTable , "" )
217
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
211
218
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
212
219
}
213
220
{
@@ -217,6 +224,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
217
224
test .S (t ).ExpectNil (err )
218
225
test .S (t ).ExpectEquals (parser .explicitSchema , "" )
219
226
test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
227
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
220
228
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
221
229
}
222
230
{
@@ -226,6 +234,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
226
234
test .S (t ).ExpectNil (err )
227
235
test .S (t ).ExpectEquals (parser .explicitSchema , "" )
228
236
test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
237
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
229
238
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
230
239
}
231
240
{
@@ -235,6 +244,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
235
244
test .S (t ).ExpectNil (err )
236
245
test .S (t ).ExpectEquals (parser .explicitSchema , "scm with spaces" )
237
246
test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
247
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
238
248
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
239
249
}
240
250
{
@@ -244,6 +254,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
244
254
test .S (t ).ExpectNil (err )
245
255
test .S (t ).ExpectEquals (parser .explicitSchema , "scm" )
246
256
test .S (t ).ExpectEquals (parser .explicitTable , "tbl with spaces" )
257
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
247
258
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
248
259
}
249
260
{
@@ -253,6 +264,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
253
264
test .S (t ).ExpectNil (err )
254
265
test .S (t ).ExpectEquals (parser .explicitSchema , "scm" )
255
266
test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
267
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
256
268
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
257
269
}
258
270
{
@@ -262,6 +274,7 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
262
274
test .S (t ).ExpectNil (err )
263
275
test .S (t ).ExpectEquals (parser .explicitSchema , "scm" )
264
276
test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
277
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
265
278
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
266
279
}
267
280
{
@@ -271,6 +284,17 @@ func TestParseAlterStatementExplicitTable(t *testing.T) {
271
284
test .S (t ).ExpectNil (err )
272
285
test .S (t ).ExpectEquals (parser .explicitSchema , "scm" )
273
286
test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
287
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b" )
274
288
test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" }))
275
289
}
290
+ {
291
+ parser := NewAlterTableParser ()
292
+ statement := "alter table scm.tbl drop column b, add index idx(i)"
293
+ err := parser .ParseAlterStatement (statement )
294
+ test .S (t ).ExpectNil (err )
295
+ test .S (t ).ExpectEquals (parser .explicitSchema , "scm" )
296
+ test .S (t ).ExpectEquals (parser .explicitTable , "tbl" )
297
+ test .S (t ).ExpectEquals (parser .alterStatementOptions , "drop column b, add index idx(i)" )
298
+ test .S (t ).ExpectTrue (reflect .DeepEqual (parser .alterTokens , []string {"drop column b" , "add index idx(i)" }))
299
+ }
276
300
}
0 commit comments