def test_multiple_table_select(self): self.assert_parsed_select( 'SELECT foo FROM table1, table2', tq_ast.Select([tq_ast.SelectField(tq_ast.ColumnId('foo'), None)], tq_ast.TableUnion([ tq_ast.TableId('table1', None), tq_ast.TableId('table2', None), ]), None, None, None, None, None))
def p_table_expr_table_or_union(p): """full_table_expr : aliased_table_expr_list""" # Unions are special in their naming rules, so we only call a table list a # union if it has at least two tables. Otherwise, it's just a table. if len(p[1]) == 1: p[0] = p[1][0] else: p[0] = tq_ast.TableUnion(p[1])
def test_redundant_commas_allowed(self): # In most cases, a comma at the end of a comma-separated list is OK. self.assert_parsed_select( 'SELECT foo IN (1, 2, 3,), bar, FROM table1, table2, ' 'GROUP BY col1, col2,', tq_ast.Select([ tq_ast.SelectField( tq_ast.FunctionCall('in', [ tq_ast.ColumnId('foo'), tq_ast.Literal(1), tq_ast.Literal(2), tq_ast.Literal(3) ]), None), tq_ast.SelectField(tq_ast.ColumnId('bar'), None) ], tq_ast.TableUnion([ tq_ast.TableId('table1', None), tq_ast.TableId('table2', None) ]), None, [tq_ast.ColumnId('col1'), tq_ast.ColumnId('col2')], None, None, None))