From 8d4a52c9d014047baecbdab76f48eb729e3842dc Mon Sep 17 00:00:00 2001 From: Diego Medina Date: Fri, 15 Apr 2022 14:55:04 -0400 Subject: [PATCH] fix(sql lab): add quotes when autocompleting table names with spaces in the editor (#19311) --- .../src/SqlLab/components/AceEditorWrapper/index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx index e2e141608c61..53ec3f808a62 100644 --- a/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx +++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper/index.tsx @@ -227,11 +227,15 @@ class AceEditorWrapper extends React.PureComponent { this.props.queryEditor.schema, ); } + + let { caption } = data; + if (data.meta === 'table' && caption.includes(' ')) { + 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) ? '' : ' '}`, ); }, };