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

Function identifierNeedsQuoting

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

identifierNeedsQuoting reports whether name must be backtick-quoted to be a valid bare identifier: it is empty, contains a character outside [letter,digit,_,$], starts with a digit, or is a reserved keyword.

(name string)

Source from the content-addressed store, hash-verified

363// valid bare identifier: it is empty, contains a character outside
364// [letter,digit,_,$], starts with a digit, or is a reserved keyword.
365func identifierNeedsQuoting(name string) bool {
366 if name == "" {
367 return true
368 }
369 for _, r := range name {
370 if !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != '_' && r != '$' {
371 return true
372 }
373 }
374 if unicode.IsDigit(rune(name[0])) {
375 return true
376 }
377 return isReservedKeyword(name)
378}
379
380// isReservedKeyword reports whether a bare-shaped name is a reserved keyword
381// that cannot be used as an unquoted identifier. omni exposes no reserved-word

Callers 1

quoteIdentifierIfNeededFunction · 0.70

Calls 1

isReservedKeywordFunction · 0.85

Tested by

no test coverage detected