Exemplo n.º 1
0
def test_matches_correct_order():
    s = sql.select([sql.column("beef")
                    ]).where(sql.column("beef").match("cow")).compile(
                        compile_kwargs={"literal_binds": True},
                        dialect=bq.BQDialect())
    assert "WHERE beef CONTAINS 'cow'" in str(s)
Exemplo n.º 2
0
def test_string_literals_not_oldstyle_quoted_in_func():
    s = str(
        sql.case([(sql.column("WHOA") == "Jason's", 1)],
                 else_=0).compile(compile_kwargs={"literal_binds": True},
                                  dialect=bq.BQDialect()))
    assert "Jason's" not in s
Exemplo n.º 3
0
def test_limit_compiles_correctly():
    s = sql.select([sql.column('col1'), sql.column('col2')]).select_from(
        sql.table('table_name')).limit(5).compile(dialect=bq.BQDialect())
    assert ('LIMIT 5' in str(s)) and ('TOP 5' not in str(s))
Exemplo n.º 4
0
def test_string_literals_correctly_quoted():
    s = sql.select([
        func.look_at(sql.column("something") == "here's a single-quote")
    ]).select_from(sql.table("something_else")).compile(
        compile_kwargs={"literal_binds": True}, dialect=bq.BQDialect())
    assert "here\\'s" in str(s)
Exemplo n.º 5
0
def test_string_literal_does_not_use_old_sql_quote_escaping():
    s = sql.select([
        func.look_at(sql.column("something") == "here's a single-quote")
    ]).select_from(sql.table("something_else")).compile(
        compile_kwargs={"literal_binds": True}, dialect=bq.BQDialect())
    assert "here''s" not in str(s)
Exemplo n.º 6
0
def test_mixed_case_column_not_quoted():
    s = sql.select([sql.column("Pork")]).compile(dialect=bq.BQDialect())
    assert "[Pork]" not in str(s)
    assert "Pork" in str(s)
Exemplo n.º 7
0
def test_table_is_quoted_with_square_brackets():
    s = sql.select([func.sum().label("Pork")]).select_from(
        sql.table("with.dot")).compile(dialect=bq.BQDialect())
    assert "[with.dot]" in str(s)
Exemplo n.º 8
0
def test_mixed_case_function_label_not_quoted():
    s = sql.select([func.sum().label("Pork")]).compile(dialect=bq.BQDialect())
    assert "[Pork]" not in str(s)
    assert "Pork" in str(s)