-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support of 'OR UPDATE|IGNORE' syntax for INSERT DML (#79)
* Add support of 'OR UPDATE|INGORE' syntax for INSERT DML See: https://cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax#insert-ignore * Update test cases * Update ast/ast.go Co-authored-by: Hiroya Fujinami <[email protected]> --------- Co-authored-by: Hiroya Fujinami <[email protected]>
- Loading branch information
1 parent
0a1141e
commit f02fa7b
Showing
20 changed files
with
311 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT OR IGNORE INTO foo | ||
(foo, bar) VALUES (1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT OR UPDATE INTO foo | ||
(foo, bar) VALUES (1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- insert_or_ignore.sql | ||
INSERT OR IGNORE INTO foo | ||
(foo, bar) VALUES (1, 2) | ||
--- AST | ||
&ast.Insert{ | ||
Insert: 0, | ||
InsertOrType: "IGNORE", | ||
TableName: &ast.Ident{ | ||
NamePos: 22, | ||
NameEnd: 25, | ||
Name: "foo", | ||
}, | ||
Columns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 27, | ||
NameEnd: 30, | ||
Name: "foo", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 32, | ||
NameEnd: 35, | ||
Name: "bar", | ||
}, | ||
}, | ||
Input: &ast.ValuesInput{ | ||
Values: 37, | ||
Rows: []*ast.ValuesRow{ | ||
&ast.ValuesRow{ | ||
Lparen: 44, | ||
Rparen: 49, | ||
Exprs: []*ast.DefaultExpr{ | ||
&ast.DefaultExpr{ | ||
DefaultPos: -1, | ||
Default: false, | ||
Expr: &ast.IntLiteral{ | ||
ValuePos: 45, | ||
ValueEnd: 46, | ||
Base: 10, | ||
Value: "1", | ||
}, | ||
}, | ||
&ast.DefaultExpr{ | ||
DefaultPos: -1, | ||
Default: false, | ||
Expr: &ast.IntLiteral{ | ||
ValuePos: 48, | ||
ValueEnd: 49, | ||
Base: 10, | ||
Value: "2", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
--- SQL | ||
INSERT OR IGNORE INTO foo (foo, bar) VALUES (1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- insert_or_update.sql | ||
INSERT OR UPDATE INTO foo | ||
(foo, bar) VALUES (1, 2) | ||
--- AST | ||
&ast.Insert{ | ||
Insert: 0, | ||
InsertOrType: "UPDATE", | ||
TableName: &ast.Ident{ | ||
NamePos: 22, | ||
NameEnd: 25, | ||
Name: "foo", | ||
}, | ||
Columns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 27, | ||
NameEnd: 30, | ||
Name: "foo", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 32, | ||
NameEnd: 35, | ||
Name: "bar", | ||
}, | ||
}, | ||
Input: &ast.ValuesInput{ | ||
Values: 37, | ||
Rows: []*ast.ValuesRow{ | ||
&ast.ValuesRow{ | ||
Lparen: 44, | ||
Rparen: 49, | ||
Exprs: []*ast.DefaultExpr{ | ||
&ast.DefaultExpr{ | ||
DefaultPos: -1, | ||
Default: false, | ||
Expr: &ast.IntLiteral{ | ||
ValuePos: 45, | ||
ValueEnd: 46, | ||
Base: 10, | ||
Value: "1", | ||
}, | ||
}, | ||
&ast.DefaultExpr{ | ||
DefaultPos: -1, | ||
Default: false, | ||
Expr: &ast.IntLiteral{ | ||
ValuePos: 48, | ||
ValueEnd: 49, | ||
Base: 10, | ||
Value: "2", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
--- SQL | ||
INSERT OR UPDATE INTO foo (foo, bar) VALUES (1, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- insert_or_ignore.sql | ||
INSERT OR IGNORE INTO foo | ||
(foo, bar) VALUES (1, 2) | ||
--- AST | ||
&ast.Insert{ | ||
Insert: 0, | ||
InsertOrType: "IGNORE", | ||
TableName: &ast.Ident{ | ||
NamePos: 22, | ||
NameEnd: 25, | ||
Name: "foo", | ||
}, | ||
Columns: []*ast.Ident{ | ||
&ast.Ident{ | ||
NamePos: 27, | ||
NameEnd: 30, | ||
Name: "foo", | ||
}, | ||
&ast.Ident{ | ||
NamePos: 32, | ||
NameEnd: 35, | ||
Name: "bar", | ||
}, | ||
}, | ||
Input: &ast.ValuesInput{ | ||
Values: 37, | ||
Rows: []*ast.ValuesRow{ | ||
&ast.ValuesRow{ | ||
Lparen: 44, | ||
Rparen: 49, | ||
Exprs: []*ast.DefaultExpr{ | ||
&ast.DefaultExpr{ | ||
DefaultPos: -1, | ||
Default: false, | ||
Expr: &ast.IntLiteral{ | ||
ValuePos: 45, | ||
ValueEnd: 46, | ||
Base: 10, | ||
Value: "1", | ||
}, | ||
}, | ||
&ast.DefaultExpr{ | ||
DefaultPos: -1, | ||
Default: false, | ||
Expr: &ast.IntLiteral{ | ||
ValuePos: 48, | ||
ValueEnd: 49, | ||
Base: 10, | ||
Value: "2", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
--- SQL | ||
INSERT OR IGNORE INTO foo (foo, bar) VALUES (1, 2) |
Oops, something went wrong.