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

Function findMySQLKeywordBefore

backend/plugin/db/mysql/query.go:301–317  ·  view source on GitHub ↗
(sql string, offset int, keyword string)

Source from the content-addressed store, hash-verified

299}
300
301func findMySQLKeywordBefore(sql string, offset int, keyword string) int {
302 if offset > len(sql) {
303 offset = len(sql)
304 }
305 if len(keyword) == 0 {
306 return offset
307 }
308 keyword = strings.ToUpper(keyword)
309 tokens := omnimysqlparser.Tokenize(sql[:offset])
310 for i := len(tokens) - 1; i >= 0; i-- {
311 token := tokens[i]
312 if token.End <= offset && omnimysqlparser.TokenName(token.Type) == keyword {
313 return token.Loc
314 }
315 }
316 return offset
317}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected