-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
fix(sql lab): add quotes when autocompleting table names with spaces in the editor #19311
fix(sql lab): add quotes when autocompleting table names with spaces in the editor #19311
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19311 +/- ##
==========================================
- Coverage 66.65% 66.64% -0.01%
==========================================
Files 1672 1674 +2
Lines 64611 64606 -5
Branches 6505 6501 -4
==========================================
- Hits 43066 43058 -8
- Misses 19862 19865 +3
Partials 1683 1683
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -221,11 +221,15 @@ class AceEditorWrapper extends React.PureComponent<Props, State> { | |||
this.props.queryEditor.schema, | |||
); | |||
} | |||
|
|||
let { caption } = data; | |||
if (data.meta === 'table' && caption.includes(' ')) { |
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.
Actually, we don't need to check if the caption contains space or not, because adding quotes to table name will always work fine. So you don't need this condition again, just add your expression into above condition.
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.
It works fine, but it doesn't look good. We should only add it when needed
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.
@codemaster08240328 any updates here?
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.
LGTM!
SUMMARY
The SQL autocomplete in the SQL Lab editor work with the tables loaded from the schema.
The autocomplete works, but if the table has spaces, the query won't work as it's not properly escaped.
This PR adds quotes around the table name if it has spaces in it.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
Screen.Recording.2022-03-22.at.14.21.21.mov
After:
Screen.Recording.2022-03-22.at.14.22.40.mov
TESTING INSTRUCTIONS
Ensure the autocompleted table has quotes if the name has spaces in it.
ADDITIONAL INFORMATION