michael-s-molina commented on code in PR #41492:
URL: https://github.com/apache/superset/pull/41492#discussion_r3505797781
##########
superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts:
##########
@@ -54,12 +55,25 @@ const getHelperText = (value: string) =>
};
// Names that aren't simple identifiers (spaces, punctuation, leading digits)
-// must be double-quoted to be valid SQL, with embedded quotes doubled.
+// must be quoted to be valid SQL. Most engines use ANSI double quotes, but a
+// few use dialect-specific characters: MySQL/MariaDB use backticks and SQL
+// Server uses square brackets. Embedded quote characters are escaped by
+// doubling (for brackets, only the closing bracket needs escaping).
const SIMPLE_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
-const quoteIdentifier = (identifier: string) =>
- SIMPLE_IDENTIFIER_RE.test(identifier)
- ? identifier
- : `"${identifier.replace(/"/g, '""')}"`;
+const quoteIdentifier = (identifier: string, backend?: string) => {
+ if (SIMPLE_IDENTIFIER_RE.test(identifier)) {
+ return identifier;
+ }
+ switch (backend) {
Review Comment:
@rusackas I think this should be handled by the database engine spec instead
of here.
--
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]