Пример #1
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'LIMIT')
     if not isinstance(p.constant.value, int):
         raise ParsingException(
             f'LIMIT must be an integer value, got: {p.constant.value}')
     select.limit = p.constant
     return select
Пример #2
0
    def select(self, p):
        select = p.select
        ensure_select_keyword_order(select, 'GROUP BY')
        group_by = p.expr_list
        if not isinstance(group_by, list):
            group_by = [group_by]

        select.group_by = group_by
        return select
Пример #3
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'WHERE')
     where_expr = p.expr
     if not isinstance(where_expr, Operation):
         raise ParsingException(
             f"WHERE must contain an operation that evaluates to a boolean, got: {str(where_expr)}"
         )
     select.where = where_expr
     return select
Пример #4
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'HAVING')
     having = p.expr
     if not isinstance(having, Operation):
         raise ParsingException(
             f"HAVING must contain an operation that evaluates to a boolean, got: {str(having)}"
         )
     select.having = having
     return select
Пример #5
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'LIMIT')
     if not isinstance(p.constant0.value, int) or not isinstance(
             p.constant1.value, int):
         raise ParsingException(
             f'LIMIT must have integer arguments, got: {p.constant0.value}, {p.constant1.value}'
         )
     select.offset = p.constant0
     select.limit = p.constant1
     return select
Пример #6
0
    def select(self, p):
        select = p.select
        if select.offset is not None:
            raise ParsingException(f'OFFSET already specified for this query')
        ensure_select_keyword_order(select, 'OFFSET')
        if not isinstance(p.constant.value, int):
            raise ParsingException(
                f'OFFSET must be an integer value, got: {p.constant.value}')

        select.offset = p.constant
        return select
Пример #7
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'FROM')
     select.from_table = p.from_table_aliased
     return select
Пример #8
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'FROM')
     select.from_table = Identifier(p.TABLES)
     return select
Пример #9
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'ORDER BY')
     select.order_by = p.ordering_terms
     return select
Пример #10
0
 def select(self, p):
     select = p.select
     ensure_select_keyword_order(select, 'MODE')
     select.mode = 'FOR UPDATE'
     return select