Adding upstream version 1.31.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
9aaa9c7fe0
commit
5829a372a2
23 changed files with 166 additions and 107 deletions
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
from mycli.packages.parseutils import (
|
||||
extract_tables,
|
||||
extract_tables_from_complete_statements,
|
||||
query_starts_with,
|
||||
queries_start_with,
|
||||
is_destructive,
|
||||
|
@ -77,7 +78,6 @@ def test_simple_insert_single_table():
|
|||
assert tables == [(None, "abc", "abc")]
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_simple_insert_single_table_schema_qualified():
|
||||
tables = extract_tables('insert into abc.def (id, name) values (1, "def")')
|
||||
assert tables == [("abc", "def", None)]
|
||||
|
@ -108,6 +108,22 @@ def test_join_as_table():
|
|||
assert tables == [(None, "my_table", "m")]
|
||||
|
||||
|
||||
def test_extract_tables_from_complete_statements():
|
||||
tables = extract_tables_from_complete_statements("SELECT * FROM my_table AS m WHERE m.a > 5")
|
||||
assert tables == [(None, "my_table", "m")]
|
||||
|
||||
|
||||
def test_extract_tables_from_complete_statements_cte():
|
||||
tables = extract_tables_from_complete_statements("WITH my_cte (id, num) AS ( SELECT id, COUNT(1) FROM my_table GROUP BY id ) SELECT *")
|
||||
assert tables == [(None, "my_table", None)]
|
||||
|
||||
|
||||
# this would confuse plain extract_tables() per #1122
|
||||
def test_extract_tables_from_multiple_complete_statements():
|
||||
tables = extract_tables_from_complete_statements(r'\T sql-insert; SELECT * FROM my_table AS m WHERE m.a > 5')
|
||||
assert tables == [(None, "my_table", "m")]
|
||||
|
||||
|
||||
def test_query_starts_with():
|
||||
query = "USE test;"
|
||||
assert query_starts_with(query, ("use",)) is True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue