villebro opened a new pull request #17111: URL: https://github.com/apache/superset/pull/17111
### SUMMARY When executing a query with a virtual table that contains a literal value with a colon suffixed by text characters, SQLAlchemy interprets these as being bind paramters. This PR ensures that these are escaped using the same pattern that SQLAlchemy uses to detect bind parameters (the regex is available as a private variable in `TextClause`). Relevant test cases are added (notice that the Postgres cast to `::TIMESTAMP` is not escaped, as SQLAlchemy doesn't consider it to be a bind paramter). Closes #17098 When executing the query `SELECT ':00 :abc' as abc, 123 as num` in SQL Lab, the query executes succesfully:  ### BEFORE When used as a virtual table in a chart query, SQLAlchemy interprets there to be two bind parameters present, namely `00` and `abc`, resulting in the following error:  ### AFTER After escaping the bind-like strings, the query renders as expected.  ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
