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

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

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 4
0
 def test_select_with_multiple_tables(self):
     sql = """SELECT count(table2.id)
         FROM table1, table2, table2
         WHERE table2.id = table1.table2_id
     """
     actual = extract_signature(sql)
     self.assertEqual("SELECT FROM table1", actual)
Ejemplo n.º 5
0
    def test_select_subselect_with_alias(self):
        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)

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 6
0
    def test_select_subselect_with_alias(self):
        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)

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 7
0
    def test_select_with_entity_quotes(self):
        sql = """SELECT `id`, `name` FROM `mytable` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 8
0
    def test_delete(self):
        sql = """DELETE FROM `mytable` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("DELETE FROM mytable", actual)
Ejemplo n.º 9
0
    def test_update(self):
        sql = """UPDATE `mytable` set name='Ron' WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("UPDATE mytable", actual)
Ejemplo n.º 10
0
    def test_multi_statement_sql(self):
        sql = """CREATE TABLE mytable; SELECT * FROM mytable; DROP TABLE mytable"""
        actual = extract_signature(sql)

        self.assertEqual("CREATE TABLE", actual)
Ejemplo n.º 11
0
    def test_multi_statement_sql(self):
        sql = """CREATE TABLE mytable; SELECT * FROM mytable; DROP TABLE mytable"""
        actual = extract_signature(sql)

        self.assertEqual("CREATE TABLE", actual)
Ejemplo n.º 12
0
    def test_select_with_difficult_table_name(self):
        sql = "SELECT id FROM `myta\n-æøåble` WHERE id = 2323" ""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM myta\n-æøåble", actual)
Ejemplo n.º 13
0
    def test_update(self):
        sql = """UPDATE `mytable` set name='Ron' WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("UPDATE mytable", actual)
Ejemplo n.º 14
0
    def test_insert(self):
        sql = """INSERT INTO `mytable` (id, name) VALUE ('2323', 'Ron')"""
        actual = extract_signature(sql)

        self.assertEqual("INSERT INTO mytable", actual)
Ejemplo n.º 15
0
    def test_select_with_invalid_literal(self):
        sql = "SELECT \"neverending literal FROM (SELECT * FROM ..." ""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM", actual)
Ejemplo n.º 16
0
    def test_delete(self):
        sql = """DELETE FROM `mytable` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("DELETE FROM mytable", actual)
Ejemplo n.º 17
0
    def test_insert(self):
        sql = """INSERT INTO `mytable` (id, name) VALUE ('2323', 'Ron')"""
        actual = extract_signature(sql)

        self.assertEqual("INSERT INTO mytable", actual)
Ejemplo n.º 18
0
    def test_select_with_entity_quotes(self):
        sql = """SELECT `id`, `name` FROM `mytable` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 19
0
    def test_select_with_difficult_values(self):
        sql = """SELECT id, 'some \\'name' + " from Denmark" FROM `mytable` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 20
0
    def test_select_with_invalid_literal(self):
        sql = "SELECT \"neverending literal FROM (SELECT * FROM ..."""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM", actual)
Ejemplo n.º 21
0
    def test_select_with_difficult_table_name(self):
        sql = "SELECT id FROM `myta\n-æøåble` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM myta\n-æøåble", actual)
Ejemplo n.º 22
0
    def test_begin(self):
        sql = """BEGIN"""
        actual = extract_signature(sql)

        self.assertEqual("BEGIN", actual)
Ejemplo n.º 23
0
    def test_savepoint(self):
        sql = """SAVEPOINT x_asd1234"""
        actual = extract_signature(sql)

        self.assertEqual("SAVEPOINT", actual)
Ejemplo n.º 24
0
    def test_select_with_difficult_values(self):
        sql = """SELECT id, 'some \\'name' + " from Denmark" FROM `mytable` WHERE id = 2323"""
        actual = extract_signature(sql)

        self.assertEqual("SELECT FROM mytable", actual)
Ejemplo n.º 25
0
    def test_begin(self):
        sql = """BEGIN"""
        actual = extract_signature(sql)

        self.assertEqual("BEGIN", actual)
Ejemplo n.º 26
0
    def test_create_index_with_name(self):
        sql = """CREATE INDEX myindex ON mytable"""
        actual = extract_signature(sql)

        self.assertEqual("CREATE INDEX", actual)
Ejemplo n.º 27
0
    def test_savepoint(self):
        sql = """SAVEPOINT x_asd1234"""
        actual = extract_signature(sql)

        self.assertEqual("SAVEPOINT", actual)
Ejemplo n.º 28
0
    def test_drop_table(self):
        sql = """DROP TABLE mytable"""
        actual = extract_signature(sql)

        self.assertEqual("DROP TABLE", actual)
Ejemplo n.º 29
0
    def test_create_index_with_name(self):
        sql = """CREATE INDEX myindex ON mytable"""
        actual = extract_signature(sql)

        self.assertEqual("CREATE INDEX", actual)
Ejemplo n.º 30
0
    def test_drop_table(self):
        sql = """DROP TABLE mytable"""
        actual = extract_signature(sql)

        self.assertEqual("DROP TABLE", actual)