-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bigquery: allow string escaping #27
bigquery: allow string escaping #27
Conversation
bigquery().verified_only_select(r#"SELECT CAST(TRIM(NULLIF(TRIM(JSON_QUERY(json_dump, "$.email_verified")), ''), '\"') AS BOOL) AS is_email_verified FROM foo"#); | ||
bigquery().verified_only_select(r#"SELECT CAST(LTRIM(NULLIF(TRIM(JSON_QUERY(json_dump, "$.email_verified")), ''), '\"') AS BOOL) AS is_email_verified FROM foo"#); | ||
bigquery().verified_only_select(r#"SELECT CAST(RTRIM(NULLIF(TRIM(JSON_QUERY(json_dump, "$.email_verified")), ''), '\"') AS BOOL) AS is_email_verified FROM foo"#); | ||
bigquery_unescaped().verified_only_select(r#"SELECT CAST(TRIM(NULLIF(TRIM(JSON_QUERY(json_dump, "$.email_verified")), ''), '\"') AS BOOL) AS is_email_verified FROM foo"#); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to use unescaped dialect logic to let validation logic check the sql
is serialised back to same value.
With escaped
(default) behaviour it is not serialised back to exact string as values are escaped and stored in AST.
@@ -845,10 +845,10 @@ fn parse_like() { | |||
|
|||
// Test with escape char | |||
let sql = &format!( | |||
"SELECT * FROM customers WHERE name {}LIKE '%a' ESCAPE '\\'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if negated { "NOT " } else { "" } | ||
); | ||
let select = bigquery().verified_only_select(sql); | ||
let select = bigquery().verified_only_select_with_canonical(sql, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as in AST the ESCAPE
is presented as escaped_character: char
it can be now only one char
generically and it won't be never serialised-deserialsed back to origin '\\'
. So using ""
as canonical format to compare (skip comparison), BUT keep next Statement
check to valid it is as expected.
Also this constraint in AST means the valid escpade format of backslash '\\'
won't be never parsed by dialect with option ParserOptions::new().with_unescape(false)
as it expect only 1 character by parser rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Why
We want to have string escaping logic also in BigQuery dialect with backslashes (https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#escape_sequences)