MCPcopy Create free account
hub / github.com/bytebase/bytebase / quoteIdentifierIfNeeded

Function quoteIdentifierIfNeeded

backend/plugin/parser/tidb/completion.go:355–360  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

353// identifier the user is typing, the name is returned unquoted (the user's
354// backticks wrap it).
355func 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

Callers 2

CompletionFunction · 0.85

Calls 2

backtickIdentifierFunction · 0.85
identifierNeedsQuotingFunction · 0.70

Tested by 1