fix(sqllab): quote autocomplete table names that need it#41199
Conversation
SQL Lab autocomplete inserted table names verbatim, so picking a name with spaces or other non-identifier characters (e.g. "COVID Vaccines") produced invalid SQL. Quote the inserted value with double quotes (and double any embedded quotes) when the name isn't a simple identifier; simple names are still inserted as-is. The display label is unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41199 +/- ##
=======================================
Coverage 64.33% 64.33%
=======================================
Files 2651 2651
Lines 144766 144771 +5
Branches 33401 33403 +2
=======================================
+ Hits 93131 93136 +5
Misses 49965 49965
Partials 1670 1670
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review Agent Run #f1a006Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
SQL Lab autocomplete inserted table names exactly as stored. When a name isn't a simple identifier (it contains spaces or punctuation, or starts with a digit), inserting it verbatim produces invalid SQL. Picking a table like
COVID Vaccinesfrom the dropdown gaveSELECT * FROM COVID Vaccines, which fails to parse.This quotes the inserted value with double quotes when the name isn't a simple identifier, doubling any embedded quotes so names containing
"stay valid. Simple identifiers are still inserted as-is, and the human-readable label shown in the dropdown is unchanged.Quoting uses ANSI double-quote identifiers. Dialect-specific quote characters (e.g. backticks on MySQL) would be a reasonable follow-up.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE:

AFTER:

TESTING INSTRUCTIONS
COVID Vaccines).FROM COVID Vaccines) and the query fails to parse.FROM "COVID Vaccines") and runs.simple_table) is still inserted without quotes.ADDITIONAL INFORMATION