Handle recursive subqueries
(l *Lexer)
| 1690 | // Handle recursive subqueries |
| 1691 | // |
| 1692 | func 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 | // |
nothing calls this directly
no test coverage detected