-
Notifications
You must be signed in to change notification settings - Fork 21
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 parsing query placeholder
?
(#95)
- Loading branch information
Showing
9 changed files
with
313 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- Origin SQL: | ||
INSERT INTO t0(user_id, message, timestamp, metric) VALUES | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?) | ||
|
||
-- Format SQL: | ||
INSERT INTO TABLE t0 | ||
(user_id, message, timestamp, metric) | ||
VALUES | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?); |
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,5 @@ | ||
INSERT INTO t0(user_id, message, timestamp, metric) VALUES | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?), | ||
(?, ?, ?, ?) |
164 changes: 164 additions & 0 deletions
164
parser/testdata/dml/output/insert_with_placeholder.sql.golden.json
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,164 @@ | ||
[ | ||
{ | ||
"InsertPos": 0, | ||
"Format": null, | ||
"Table": { | ||
"Database": null, | ||
"Table": { | ||
"Name": "t0", | ||
"QuoteType": 1, | ||
"NamePos": 12, | ||
"NameEnd": 14 | ||
} | ||
}, | ||
"ColumnNames": { | ||
"LeftParenPos": 14, | ||
"RightParenPos": 50, | ||
"ColumnNames": [ | ||
{ | ||
"Ident": { | ||
"Name": "user_id", | ||
"QuoteType": 1, | ||
"NamePos": 15, | ||
"NameEnd": 22 | ||
}, | ||
"DotIdent": null | ||
}, | ||
{ | ||
"Ident": { | ||
"Name": "message", | ||
"QuoteType": 1, | ||
"NamePos": 24, | ||
"NameEnd": 31 | ||
}, | ||
"DotIdent": null | ||
}, | ||
{ | ||
"Ident": { | ||
"Name": "timestamp", | ||
"QuoteType": 1, | ||
"NamePos": 33, | ||
"NameEnd": 42 | ||
}, | ||
"DotIdent": null | ||
}, | ||
{ | ||
"Ident": { | ||
"Name": "metric", | ||
"QuoteType": 1, | ||
"NamePos": 44, | ||
"NameEnd": 50 | ||
}, | ||
"DotIdent": null | ||
} | ||
] | ||
}, | ||
"Values": [ | ||
{ | ||
"LeftParenPos": 63, | ||
"RightParenPos": 74, | ||
"Values": [ | ||
{ | ||
"PlaceholderPos": 64, | ||
"PlaceHolderEnd": 64, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 67, | ||
"PlaceHolderEnd": 67, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 70, | ||
"PlaceHolderEnd": 70, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 73, | ||
"PlaceHolderEnd": 73, | ||
"Type": "?" | ||
} | ||
] | ||
}, | ||
{ | ||
"LeftParenPos": 81, | ||
"RightParenPos": 92, | ||
"Values": [ | ||
{ | ||
"PlaceholderPos": 82, | ||
"PlaceHolderEnd": 82, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 85, | ||
"PlaceHolderEnd": 85, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 88, | ||
"PlaceHolderEnd": 88, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 91, | ||
"PlaceHolderEnd": 91, | ||
"Type": "?" | ||
} | ||
] | ||
}, | ||
{ | ||
"LeftParenPos": 99, | ||
"RightParenPos": 110, | ||
"Values": [ | ||
{ | ||
"PlaceholderPos": 100, | ||
"PlaceHolderEnd": 100, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 103, | ||
"PlaceHolderEnd": 103, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 106, | ||
"PlaceHolderEnd": 106, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 109, | ||
"PlaceHolderEnd": 109, | ||
"Type": "?" | ||
} | ||
] | ||
}, | ||
{ | ||
"LeftParenPos": 117, | ||
"RightParenPos": 128, | ||
"Values": [ | ||
{ | ||
"PlaceholderPos": 118, | ||
"PlaceHolderEnd": 118, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 121, | ||
"PlaceHolderEnd": 121, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 124, | ||
"PlaceHolderEnd": 124, | ||
"Type": "?" | ||
}, | ||
{ | ||
"PlaceholderPos": 127, | ||
"PlaceHolderEnd": 127, | ||
"Type": "?" | ||
} | ||
] | ||
} | ||
], | ||
"SelectExpr": null | ||
} | ||
] |
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,11 @@ | ||
-- Origin SQL: | ||
SELECT * FROM t0 WHERE id = ?; | ||
|
||
-- Format SQL: | ||
|
||
SELECT | ||
* | ||
FROM | ||
t0 | ||
WHERE | ||
id = ?; |
77 changes: 77 additions & 0 deletions
77
parser/testdata/query/output/selelct_with_placeholder.sql.golden.json
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,77 @@ | ||
[ | ||
{ | ||
"SelectPos": 0, | ||
"StatementEnd": 28, | ||
"With": null, | ||
"Top": null, | ||
"SelectColumns": { | ||
"ListPos": 7, | ||
"ListEnd": 7, | ||
"HasDistinct": false, | ||
"Items": [ | ||
{ | ||
"Name": "*", | ||
"QuoteType": 0, | ||
"NamePos": 7, | ||
"NameEnd": 7 | ||
} | ||
] | ||
}, | ||
"From": { | ||
"FromPos": 9, | ||
"Expr": { | ||
"Table": { | ||
"TablePos": 14, | ||
"TableEnd": 16, | ||
"Alias": null, | ||
"Expr": { | ||
"Database": null, | ||
"Table": { | ||
"Name": "t0", | ||
"QuoteType": 1, | ||
"NamePos": 14, | ||
"NameEnd": 16 | ||
} | ||
}, | ||
"HasFinal": false | ||
}, | ||
"StatementEnd": 16, | ||
"SampleRatio": null, | ||
"HasFinal": false | ||
} | ||
}, | ||
"ArrayJoin": null, | ||
"Window": null, | ||
"Prewhere": null, | ||
"Where": { | ||
"WherePos": 17, | ||
"Expr": { | ||
"LeftExpr": { | ||
"Name": "id", | ||
"QuoteType": 1, | ||
"NamePos": 23, | ||
"NameEnd": 25 | ||
}, | ||
"Operation": "=", | ||
"RightExpr": { | ||
"PlaceholderPos": 28, | ||
"PlaceHolderEnd": 28, | ||
"Type": "?" | ||
}, | ||
"HasGlobal": false, | ||
"HasNot": false | ||
} | ||
}, | ||
"GroupBy": null, | ||
"WithTotal": false, | ||
"Having": null, | ||
"OrderBy": null, | ||
"LimitBy": null, | ||
"Limit": null, | ||
"Settings": null, | ||
"Format": null, | ||
"UnionAll": null, | ||
"UnionDistinct": null, | ||
"Except": null | ||
} | ||
] |
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 @@ | ||
SELECT * FROM t0 WHERE id = ?; |