betodealmeida commented on PR #34413:
URL: https://github.com/apache/superset/pull/34413#issuecomment-3140280689

   > According to GPT this change might break valid SQL.
   
   Yeah, the problem with `sqlparse` is that we were using it to parse 
"Schrödinger's SQL" — SQL that was neither valid nor invalid until we tried to 
run it. 😂 Let me give an example, here's a unit test that broke while I was 
working on this issue (this test addresses 
https://github.com/andialbrecht/sqlparse/issues/652):
   
   ```python
   def test_sqlparse_issue_652():
       stmt = sqlparse.parse(r"foo = '\' AND bar = 'baz'")[0]
       assert len(stmt.tokens) == 5
   ```
   
   Is this SQL expression valid or invalid?
   
   ```sql
   foo = '\' AND bar = 'baz'
   ```
   
   The answer is "it depends": Postgres uses the `'` for escaping sinqle 
quotes, so this works. But for MySQL, this is an unterminated string, since the 
first single quote matches the third, and the last single quote doesn't have a 
match.
   
   That being said, I think the example you gave is common enough that we 
should make sure it can be parsed. I'm adding a new unit test and updating the 
regex.


-- 
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