Skip to content
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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,15 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
this.props.queryEditor.schema,
);
}

let { caption } = data;
if (data.meta === 'table' && caption.includes(' ')) {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codemaster08240328 any updates here?

caption = `"${caption}"`;
}

// executing https://github.com/thlorenz/brace/blob/3a00c5d59777f9d826841178e1eb36694177f5e6/ext/language_tools.js#L1448
editor.completer.insertMatch(
`${data.caption}${
['function', 'schema'].includes(data.meta) ? '' : ' '
}`,
`${caption}${['function', 'schema'].includes(data.meta) ? '' : ' '}`,
);
},
};
Expand Down