예제 #1
0
def test_to_sql():
    term = As('test', 'a0')
    sql = Sql(term.to_sql())
    assert str(sql) == '"test" AS "a0"'
예제 #2
0
def test_to_sql():
    term = ArrayAgg('test')
    sql = Sql(term.to_sql())
    assert str(sql) == 'array_agg("test")'
예제 #3
0
def test_recursive_expression():
    term = CTE('test')
    term.append('cte0').set_recursive_expression(Relation('rcrs'))
    sql = Sql(term.to_sql())
    assert str(sql) == 'WITH RECURSIVE "c0" AS ("cte0" UNION ALL "rcrs") "test"'
예제 #4
0
def test_nested_expression():
    term = As(As('test', 'a0'), 'a1')
    sql = Sql(term.to_sql())
    assert str(sql) == '"test" AS "a0" AS "a1"'
예제 #5
0
def test_prepend():
    term = CTE('test')
    term.prepend('cte0')
    term.prepend('cte1')
    sql = Sql(term.to_sql())
    assert str(sql) == 'WITH "c1" AS ("cte1"), "c0" AS ("cte0") "test"'
예제 #6
0
def test_to_sql():
    term = CTE('test')
    sql = Sql(term.to_sql())
    assert str(sql) == '"test"'
예제 #7
0
def test_to_sql_with_no_column():
    alias = Alias('test')
    sql = Sql(alias.to_sql())
    assert str(sql) == '"test"'
예제 #8
0
def test_to_sql_with_column():
    alias = Alias('test', column='a')
    sql = Sql(alias.to_sql())
    assert str(sql) == '"test"."a"'
예제 #9
0
def test_with_where():
    where_mock = MagicMock()
    where_mock.get_sql.return_value = Identifier('f0'), ()
    term = Delete('test', where=where_mock)
    sql = Sql(term.to_sql())
    assert str(sql) == 'DELETE FROM "test" WHERE "f0"'
예제 #10
0
def test_with_returning():
    term = Delete('test', returning=('f0', 'f1'))
    sql = Sql(term.to_sql())
    assert str(sql) == 'DELETE FROM "test" RETURNING "f0", "f1"'
예제 #11
0
def test_to_sql():
    term = Delete('test')
    sql = Sql(term.to_sql())
    assert str(sql) == 'DELETE FROM "test"'