quoteIdentifierIfNeeded backtick-quotes an object identifier when it would otherwise be invalid as a bare identifier, so that accepting the completion inserts valid SQL. When the caret already sits inside a backtick-quoted identifier the user is typing, the name is returned unquoted (the user's back
(name string, caretInBacktick bool)
| 353 | // identifier the user is typing, the name is returned unquoted (the user's |
| 354 | // backticks wrap it). |
| 355 | func quoteIdentifierIfNeeded(name string, caretInBacktick bool) string { |
| 356 | if caretInBacktick || !identifierNeedsQuoting(name) { |
| 357 | return name |
| 358 | } |
| 359 | return backtickIdentifier(name) |
| 360 | } |
| 361 | |
| 362 | // identifierNeedsQuoting reports whether name must be backtick-quoted to be a |
| 363 | // valid bare identifier: it is empty, contains a character outside |