Exemplo n.º 1
0
def test_select_with_multiple_tables():
    sql = """SELECT count(table2.id)
        FROM table1, table2, table2
        WHERE table2.id = table1.table2_id
    """
    actual = extract_signature(sql)
    assert "SELECT FROM table1" == actual
Exemplo n.º 2
0
def test_select_subselect():
    sql = """SELECT id, name FROM (
            SELECT id, 'not a FROM ''value' FROM mytable WHERE id = 2323
    ) LIMIT 20"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 3
0
def test_select_subselect():
    sql = """SELECT id, name FROM (
            SELECT id, 'not a FROM ''value' FROM mytable WHERE id = 2323
    ) LIMIT 20"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 4
0
def test_select_with_multiple_tables():
    sql = """SELECT count(table2.id)
        FROM table1, table2, table2
        WHERE table2.id = table1.table2_id
    """
    actual = extract_signature(sql)
    assert "SELECT FROM table1" == actual
Exemplo n.º 5
0
def test_select_subselect_with_alias():
    sql = """
    SELECT count(*)
    FROM (
        SELECT count(id) AS some_alias, some_column
        FROM mytable
        GROUP BY some_colun
        HAVING count(id) > 1
    ) AS foo
    """
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 6
0
def test_select_subselect_with_alias():
    sql = """
    SELECT count(*)
    FROM (
        SELECT count(id) AS some_alias, some_column
        FROM mytable
        GROUP BY some_colun
        HAVING count(id) > 1
    ) AS foo
    """
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 7
0
def test_delete():
    sql = """DELETE FROM "my table" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "DELETE FROM my table" == actual
Exemplo n.º 8
0
def test_update():
    sql = """UPDATE "my table" set name='Ron' WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "UPDATE my table" == actual
Exemplo n.º 9
0
def test_multi_statement_sql():
    sql = """CREATE TABLE mytable; SELECT * FROM mytable; DROP TABLE mytable"""
    actual = extract_signature(sql)

    assert "CREATE TABLE" == actual
Exemplo n.º 10
0
def test_create_index_without_name():
    sql = """CREATE INDEX ON mytable"""
    actual = extract_signature(sql)

    assert "CREATE INDEX" == actual
Exemplo n.º 11
0
def test_select_with_difficult_table_name():
    sql = "SELECT id FROM \"myta\n-æøåble\" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM myta\n-æøåble" == actual
Exemplo n.º 12
0
def test_create_index_without_name():
    sql = """CREATE INDEX ON mytable"""
    actual = extract_signature(sql)

    assert "CREATE INDEX" == actual
Exemplo n.º 13
0
def test_begin():
    sql = """BEGIN"""
    actual = extract_signature(sql)

    assert "BEGIN" == actual
Exemplo n.º 14
0
def test_savepoint():
    sql = """SAVEPOINT x_asd1234"""
    actual = extract_signature(sql)

    assert "SAVEPOINT" == actual
Exemplo n.º 15
0
def test_select_with_invalid_literal():
    sql = "SELECT 'neverending literal FROM (SELECT * FROM ..." ""
    actual = extract_signature(sql)

    assert "SELECT FROM" == actual
Exemplo n.º 16
0
def test_select_with_invalid_subselect():
    sql = "SELECT id FROM (SELECT * " ""
    actual = extract_signature(sql)

    assert "SELECT FROM" == actual
Exemplo n.º 17
0
def test_select_with_entity_quotes():
    sql = """SELECT id, name FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 18
0
def test_drop_table():
    sql = """DROP TABLE mytable"""
    actual = extract_signature(sql)

    assert "DROP TABLE" == actual
Exemplo n.º 19
0
def test_select_with_invalid_dollar_quotes():
    sql = """SELECT id, $fish$some single doubles ' $$ + '" from Denmark' FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM" == actual
Exemplo n.º 20
0
def test_select_with_invalid_subselect():
    sql = "SELECT id FROM (SELECT * """
    actual = extract_signature(sql)

    assert "SELECT FROM" == actual
Exemplo n.º 21
0
def test_select_with_dollar_quotes_custom_token():
    sql = """SELECT id, $token $FROM $ FROM $ FROM single doubles ' $token $ + '" from Denmark' FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 22
0
def test_savepoint():
    sql = """SAVEPOINT x_asd1234"""
    actual = extract_signature(sql)

    assert "SAVEPOINT" == actual
Exemplo n.º 23
0
def test_multi_statement_sql():
    sql = """CREATE TABLE mytable; SELECT * FROM mytable; DROP TABLE mytable"""
    actual = extract_signature(sql)

    assert "CREATE TABLE" == actual
Exemplo n.º 24
0
def test_select_with_difficult_table_name():
    sql = "SELECT id FROM \"myta\n-æøåble\" WHERE id = 2323" ""
    actual = extract_signature(sql)

    assert "SELECT FROM myta\n-æøåble" == actual
Exemplo n.º 25
0
def test_select_with_invalid_literal():
    sql = "SELECT 'neverending literal FROM (SELECT * FROM ..."""
    actual = extract_signature(sql)

    assert "SELECT FROM" == actual
Exemplo n.º 26
0
def test_insert():
    sql = """INSERT INTO mytable (id, name) VALUE ('2323', 'Ron')"""
    actual = extract_signature(sql)

    assert "INSERT INTO mytable" == actual
Exemplo n.º 27
0
def test_begin():
    sql = """BEGIN"""
    actual = extract_signature(sql)

    assert "BEGIN" == actual
Exemplo n.º 28
0
def test_update_with_quotes():
    sql = """UPDATE "my table" set name='Ron' WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "UPDATE my table" == actual
Exemplo n.º 29
0
def test_drop_table():
    sql = """DROP TABLE mytable"""
    actual = extract_signature(sql)

    assert "DROP TABLE" == actual
Exemplo n.º 30
0
def test_update():
    sql = """update mytable set name = 'Ron where id = 'a'"""
    actual = extract_signature(sql)

    assert "UPDATE mytable" == actual
Exemplo n.º 31
0
def test_insert():
    sql = """INSERT INTO mytable (id, name) VALUE ('2323', 'Ron')"""
    actual = extract_signature(sql)

    assert "INSERT INTO mytable" == actual
Exemplo n.º 32
0
def test_delete_simple():
    sql = 'DELETE FROM "mytable"'
    actual = extract_signature(sql)

    assert "DELETE FROM mytable" == actual
Exemplo n.º 33
0
def test_delete_simple():
    sql = 'DELETE FROM "mytable"'
    actual = extract_signature(sql)

    assert "DELETE FROM mytable" == actual
Exemplo n.º 34
0
def test_delete():
    sql = """DELETE FROM "my table" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "DELETE FROM my table" == actual
Exemplo n.º 35
0
def test_select_simple():
    sql = """SELECT id, name FROM my_table WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM my_table" == actual
Exemplo n.º 36
0
def test_select_simple():
    sql = """SELECT id, name FROM my_table WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM my_table" == actual
Exemplo n.º 37
0
def test_select_with_difficult_values():
    sql = """SELECT id, 'some name' + '" from Denmark' FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 38
0
def test_select_with_entity_quotes():
    sql = """SELECT id, name FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 39
0
def test_select_with_dollar_quotes_custom_token():
    sql = """SELECT id, $token $FROM $ FROM $ FROM single doubles ' $token $ + '" from Denmark' FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 40
0
def test_select_with_difficult_values():
    sql = """SELECT id, 'some name' + '" from Denmark' FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 41
0
def test_select_with_dollar_quotes():
    sql = """SELECT id, $$some single doubles ' $$ + '" from Denmark' FROM "mytable" WHERE id = 2323"""
    actual = extract_signature(sql)

    assert "SELECT FROM mytable" == actual
Exemplo n.º 42
0
def test_update():
    sql = """update mytable set name = 'Ron where id = 'a'"""
    actual = extract_signature(sql)

    assert "UPDATE mytable" == actual