MCPcopy Create free account
hub / github.com/araddon/qlbridge / LexSubQuery

Function LexSubQuery

lex/lexer.go:1692–1733  ·  view source on GitHub ↗

Handle recursive subqueries

(l *Lexer)

Source from the content-addressed store, hash-verified

1690// Handle recursive subqueries
1691//
1692func LexSubQuery(l *Lexer) StateFn {
1693
1694 //u.Debugf("LexSubQuery '%v'", l.PeekX(10))
1695 l.SkipWhiteSpaces()
1696 r := l.Peek()
1697 if l.IsEnd() {
1698 return nil
1699 }
1700 if r == ')' {
1701 l.Next()
1702 l.Emit(TokenRightParenthesis)
1703 return nil
1704 }
1705
1706 /*
1707 TODO: this is a hack because the LexDialect from above should be recursive,
1708 ie support sub-queries, but doesn't currently
1709 */
1710 word := strings.ToLower(l.PeekWord())
1711 switch word {
1712 case "select":
1713 l.ConsumeWord(word)
1714 l.Emit(TokenSelect)
1715 return LexSubQuery
1716 case "where":
1717 l.ConsumeWord(word)
1718 l.Emit(TokenWhere)
1719 return LexConditionalClause
1720 case "from":
1721 l.ConsumeWord(word)
1722 l.Emit(TokenFrom)
1723 l.Push("LexSubQuery", LexSubQuery)
1724 l.Push("LexConditionalClause", LexConditionalClause)
1725 return LexTableReferences
1726 case ";":
1727 return nil
1728 default:
1729 }
1730
1731 l.Push("LexSubQuery", LexSubQuery)
1732 return LexSelectClause
1733}
1734
1735// Handle prepared statements
1736//

Callers

nothing calls this directly

Calls 8

SkipWhiteSpacesMethod · 0.80
EmitMethod · 0.80
PeekWordMethod · 0.80
ConsumeWordMethod · 0.80
PushMethod · 0.80
PeekMethod · 0.65
IsEndMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected