@@ -3685,6 +3685,34 @@ func TestParser_ParseStatement(t *testing.T) {
36853685 },
36863686 })
36873687
3688+ // Test schema-qualified table name
3689+ AssertParseStatement (t , `INSERT INTO main.tableau VALUES (1, 2), (3, 4)` , & sql.InsertStatement {
3690+ Insert : pos (0 ),
3691+ Into : pos (7 ),
3692+ Schema : & sql.Ident {NamePos : pos (12 ), Name : "main" },
3693+ Dot : pos (16 ),
3694+ Table : & sql.Ident {NamePos : pos (17 ), Name : "tableau" },
3695+ Values : pos (25 ),
3696+ ValueLists : []* sql.ExprList {
3697+ {
3698+ Lparen : pos (32 ),
3699+ Exprs : []sql.Expr {
3700+ & sql.NumberLit {ValuePos : pos (33 ), Value : "1" },
3701+ & sql.NumberLit {ValuePos : pos (36 ), Value : "2" },
3702+ },
3703+ Rparen : pos (37 ),
3704+ },
3705+ {
3706+ Lparen : pos (40 ),
3707+ Exprs : []sql.Expr {
3708+ & sql.NumberLit {ValuePos : pos (41 ), Value : "3" },
3709+ & sql.NumberLit {ValuePos : pos (44 ), Value : "4" },
3710+ },
3711+ Rparen : pos (45 ),
3712+ },
3713+ },
3714+ })
3715+
36883716 AssertParseStatementError (t , `INSERT` , `1:6: expected INTO, found 'EOF'` )
36893717 AssertParseStatementError (t , `INSERT OR` , `1:9: expected ROLLBACK, REPLACE, ABORT, FAIL, or IGNORE, found 'EOF'` )
36903718 AssertParseStatementError (t , `INSERT INTO` , `1:11: expected table name, found 'EOF'` )
@@ -3856,6 +3884,22 @@ func TestParser_ParseStatement(t *testing.T) {
38563884 }},
38573885 })
38583886
3887+ // Test schema-qualified table name
3888+ AssertParseStatement (t , `UPDATE main.tableau SET n2=n1` , & sql.UpdateStatement {
3889+ Update : pos (0 ),
3890+ Table : & sql.QualifiedTableName {
3891+ Schema : & sql.Ident {NamePos : pos (7 ), Name : "main" },
3892+ Dot : pos (11 ),
3893+ Name : & sql.Ident {NamePos : pos (12 ), Name : "tableau" },
3894+ },
3895+ Set : pos (20 ),
3896+ Assignments : []* sql.Assignment {{
3897+ Columns : []* sql.Ident {{NamePos : pos (24 ), Name : "n2" }},
3898+ Eq : pos (26 ),
3899+ Expr : & sql.Ident {NamePos : pos (27 ), Name : "n1" },
3900+ }},
3901+ })
3902+
38593903 AssertParseStatementError (t , `UPDATE` , `1:6: expected table name, found 'EOF'` )
38603904 AssertParseStatementError (t , `UPDATE OR` , `1:9: expected ROLLBACK, REPLACE, ABORT, FAIL, or IGNORE, found 'EOF'` )
38613905 AssertParseStatementError (t , `UPDATE tbl` , `1:10: expected SET, found 'EOF'` )
0 commit comments