Skip to content

Commit

Permalink
Update testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
apstndb committed Jan 9, 2025
1 parent 816a881 commit 1a971e1
Show file tree
Hide file tree
Showing 45 changed files with 805 additions and 144 deletions.
1 change: 1 addition & 0 deletions testdata/input/dml/delete_fqn.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
delete sch1.foo where foo = 1 and bar = 2
3 changes: 3 additions & 0 deletions testdata/input/dml/insert_fqn_values.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
insert sch1.foo (foo, bar, baz)
values (1, 2, 3),
(4, 5, 6)
1 change: 1 addition & 0 deletions testdata/input/dml/update_fqn.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update sch1.foo set foo = bar, bar = foo, baz = DEFAULT where foo = 1
12 changes: 8 additions & 4 deletions testdata/result/dml/!bad_insert.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ syntax error: testdata/input/dml/!bad_insert.sql:2:1: expected beginning of simp

--- AST
&ast.Insert{
TableName: &ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/delete _from.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
delete from foo where foo = 1 and bar = 2
--- AST
&ast.Delete{
TableName: &ast.Ident{
NamePos: 12,
NameEnd: 15,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 12,
NameEnd: 15,
Name: "foo",
},
},
},
Where: &ast.Where{
Where: 16,
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/delete.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
delete foo where foo = 1 and bar = 2
--- AST
&ast.Delete{
TableName: &ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
},
},
},
Where: &ast.Where{
Where: 11,
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/delete_as.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
delete foo as F where F.foo = 1
--- AST
&ast.Delete{
TableName: &ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
},
},
},
As: &ast.AsAlias{
As: 11,
Expand Down
56 changes: 56 additions & 0 deletions testdata/result/dml/delete_fqn.sql.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
--- delete_fqn.sql
delete sch1.foo where foo = 1 and bar = 2
--- AST
&ast.Delete{
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 11,
Name: "sch1",
},
&ast.Ident{
NamePos: 12,
NameEnd: 15,
Name: "foo",
},
},
},
Where: &ast.Where{
Where: 16,
Expr: &ast.BinaryExpr{
Op: "AND",
Left: &ast.BinaryExpr{
Op: "=",
Left: &ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
},
Right: &ast.IntLiteral{
ValuePos: 28,
ValueEnd: 29,
Base: 10,
Value: "1",
},
},
Right: &ast.BinaryExpr{
Op: "=",
Left: &ast.Ident{
NamePos: 34,
NameEnd: 37,
Name: "bar",
},
Right: &ast.IntLiteral{
ValuePos: 40,
ValueEnd: 41,
Base: 10,
Value: "2",
},
},
},
},
}

--- SQL
DELETE FROM sch1.foo WHERE foo = 1 AND bar = 2
12 changes: 8 additions & 4 deletions testdata/result/dml/delete_then_return.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
delete foo where foo = 1 and bar = 2 then return *
--- AST
&ast.Delete{
TableName: &ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
},
},
},
Where: &ast.Where{
Where: 11,
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/insert_cte_select.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ with cte AS (select 1 as foo, 2 as bar)
select *
--- AST
&ast.Insert{
TableName: &ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
112 changes: 112 additions & 0 deletions testdata/result/dml/insert_fqn_values.sql.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
--- insert_fqn_values.sql
insert sch1.foo (foo, bar, baz)
values (1, 2, 3),
(4, 5, 6)
--- AST
&ast.Insert{
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 11,
Name: "sch1",
},
&ast.Ident{
NamePos: 12,
NameEnd: 15,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
NamePos: 17,
NameEnd: 20,
Name: "foo",
},
&ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "bar",
},
&ast.Ident{
NamePos: 27,
NameEnd: 30,
Name: "baz",
},
},
Input: &ast.ValuesInput{
Values: 32,
Rows: []*ast.ValuesRow{
&ast.ValuesRow{
Lparen: 39,
Rparen: 47,
Exprs: []*ast.DefaultExpr{
&ast.DefaultExpr{
DefaultPos: -1,
Expr: &ast.IntLiteral{
ValuePos: 40,
ValueEnd: 41,
Base: 10,
Value: "1",
},
},
&ast.DefaultExpr{
DefaultPos: -1,
Expr: &ast.IntLiteral{
ValuePos: 43,
ValueEnd: 44,
Base: 10,
Value: "2",
},
},
&ast.DefaultExpr{
DefaultPos: -1,
Expr: &ast.IntLiteral{
ValuePos: 46,
ValueEnd: 47,
Base: 10,
Value: "3",
},
},
},
},
&ast.ValuesRow{
Lparen: 57,
Rparen: 65,
Exprs: []*ast.DefaultExpr{
&ast.DefaultExpr{
DefaultPos: -1,
Expr: &ast.IntLiteral{
ValuePos: 58,
ValueEnd: 59,
Base: 10,
Value: "4",
},
},
&ast.DefaultExpr{
DefaultPos: -1,
Expr: &ast.IntLiteral{
ValuePos: 61,
ValueEnd: 62,
Base: 10,
Value: "5",
},
},
&ast.DefaultExpr{
DefaultPos: -1,
Expr: &ast.IntLiteral{
ValuePos: 64,
ValueEnd: 65,
Base: 10,
Value: "6",
},
},
},
},
},
},
}

--- SQL
INSERT INTO sch1.foo (foo, bar, baz) VALUES (1, 2, 3), (4, 5, 6)
12 changes: 8 additions & 4 deletions testdata/result/dml/insert_into_values.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ values (1, 2, 3),
(4, 5, 6)
--- AST
&ast.Insert{
TableName: &ast.Ident{
NamePos: 12,
NameEnd: 15,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 12,
NameEnd: 15,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/insert_or_ignore.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ INSERT OR IGNORE INTO foo
--- AST
&ast.Insert{
InsertOrType: "IGNORE",
TableName: &ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/insert_or_update.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ INSERT OR UPDATE INTO foo
--- AST
&ast.Insert{
InsertOrType: "UPDATE",
TableName: &ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ THEN RETURN WITH ACTION AS act *
--- AST
&ast.Insert{
InsertOrType: "UPDATE",
TableName: &ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 22,
NameEnd: 25,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
12 changes: 8 additions & 4 deletions testdata/result/dml/insert_select.sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ insert foo (foo, bar)
select * from unnest([(1, 2), (3, 4)])
--- AST
&ast.Insert{
TableName: &ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
TableName: &ast.Path{
Idents: []*ast.Ident{
&ast.Ident{
NamePos: 7,
NameEnd: 10,
Name: "foo",
},
},
},
Columns: []*ast.Ident{
&ast.Ident{
Expand Down
Loading

0 comments on commit 1a971e1

Please sign in to comment.