rusackas commented on PR #38835:
URL: https://github.com/apache/superset/pull/38835#issuecomment-4755069346

   Fresh codex review for ya:
   
   This fixes the apostrophe case, but I think the new literal processor 
regresses other string values that `repr()` handled for us before.
   
   `_process_string_literal()` only escapes backslashes and apostrophes:
   
   ```py
   escaped = value.replace("\\", "\\\\").replace("'", "\\'")
   return f"'{escaped}'"
   ```
   
   For a value containing an actual newline, e.g. `"foo\nbar"`, this emits a 
literal newline inside a single-quoted BigQuery string:
   
   ```sql
   'foo
   bar'
   ```
   
   BigQuery rejects that form. Its lexical docs say quoted strings cannot 
contain newlines, and newlines need to be represented with escape sequences 
such as `\n`: 
https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/lexical#string_and_bytes_literals
   
   Could we preserve escaping for control characters (`\n`, `\r`, `\t`, etc.) 
while still forcing single-quoted literals and escaping apostrophes with `\'`? 
It would also be good to add a regression test for a value containing a newline.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to