コード例 #1
0
ファイル: test_parseutils.py プロジェクト: B-Rich/pgcli
def test_join_table():
    expected = {'a': 'abc', 'd': 'def'}
    tables = extract_tables('SELECT * FROM abc a JOIN def d ON a.id = d.num')
    tables_aliases = extract_tables(
        'SELECT * FROM abc a JOIN def d ON a.id = d.num', True)
    assert tables == sorted(expected.values())
    assert tables_aliases == expected
コード例 #2
0
ファイル: test_parseutils.py プロジェクト: B-Rich/pgcli
def test_join_as_table():
    expected = {'m': 'my_table'}
    assert extract_tables(
            'SELECT * FROM my_table AS m WHERE m.a > 5') == \
                    sorted(expected.values())
    assert extract_tables('SELECT * FROM my_table AS m WHERE m.a > 5',
                          True) == expected
コード例 #3
0
def test_incomplete_join_clause():
    sql = '''select a.x, b.y
             from abc a join bcd b
             on a.id = '''
    tables = extract_tables(sql)
    assert tables == ((None, 'abc', 'a', False),
                      (None, 'bcd', 'b', False))
コード例 #4
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_insert_single_table():
    tables = extract_tables('insert into abc (id, name) values (1, "def")')

    # sqlparse mistakenly assigns an alias to the table
    # AND mistakenly identifies the field list as
    # assert tables == [(None, 'abc', None, False)]

    assert tables == [(None, 'abc', 'abc', False)]
コード例 #5
0
def test_simple_insert_single_table():
    tables = extract_tables('insert into abc (id, name) values (1, "def")')

    # sqlparse mistakenly assigns an alias to the table
    # AND mistakenly identifies the field list as
    # assert tables == [(None, 'abc', None, False)]

    assert tables == [(None, 'abc', 'abc', False)]
コード例 #6
0
def test_multiple_joins():
    sql = '''select * from t1
            inner join t2 ON
              t1.id = t2.t1_id
            inner join t3 ON
              t2.id = t3.'''
    tables = extract_tables(sql)
    assert tables == ((None, 't1', None, False), (None, 't2', None, False),
                      (None, 't3', None, False))
コード例 #7
0
def test_multiple_joins():
    sql = '''select * from t1
            inner join t2 ON
              t1.id = t2.t1_id
            inner join t3 ON
              t2.id = t3.'''
    tables = extract_tables(sql)
    assert tables == (
        (None, 't1', None, False),
        (None, 't2', None, False),
        (None, 't3', None, False))
コード例 #8
0
def test_empty_string():
    tables = extract_tables('')
    assert tables == []
コード例 #9
0
def test_simple_select_with_cols_multiple_tables():
    tables = extract_tables('select a,b from abc, def')
    assert sorted(tables) == [(None, 'abc', None), (None, 'def', None)]
コード例 #10
0
def test_simple_insert_single_table():
    tables = extract_tables('insert into abc (id, name) values (1, "def")')

    # sqlparse mistakenly assigns an alias to the table
    # assert tables == [(None, 'abc', None)]
    assert tables == [(None, 'abc', 'abc')]
コード例 #11
0
def test_empty_string():
    tables = extract_tables('')
    assert tables == []
コード例 #12
0
def test_simple_select_multiple_tables_schema_qualified():
    tables = extract_tables('select * from abc.def, ghi.jkl')
    assert sorted(tables) == [('abc', 'def', None), ('ghi', 'jkl', None)]
コード例 #13
0
def test_simple_update_table():
    tables = extract_tables('update abc set id = 1')
    assert tables == [(None, 'abc', None)]
コード例 #14
0
def test_simple_select_single_table_schema_qualified():
    tables = extract_tables('select * from abc.def')
    assert tables == [('abc', 'def', None, False)]
コード例 #15
0
def test_simple_select_with_cols_single_table():
    tables = extract_tables('select a,b from abc')
    assert tables == [(None, 'abc', None, False)]
コード例 #16
0
def test_simple_select_multiple_tables():
    tables = extract_tables('select * from abc, def')
    assert sorted(tables) == [(None, 'abc', None, False),
                              (None, 'def', None, False)]
コード例 #17
0
def test_complex_table_and_function():
    tables = extract_tables('''SELECT * FROM foo.bar baz
                               JOIN bar.qux(x, y, z) quux''')
    assert tables == [('foo', 'bar', 'baz', False),
                      ('bar', 'qux', 'quux', True)]
コード例 #18
0
def test_simple_table_and_function():
    tables = extract_tables('SELECT * FROM foo JOIN bar()')
    assert tables == [(None, 'foo', None, False),
                      (None, 'bar', None, True)]
コード例 #19
0
def test_select_with_hanging_comma_multiple_tables():
    tables = extract_tables('select a, from abc, def')
    assert sorted(tables) == [(None, 'abc', None), (None, 'def', None)]
コード例 #20
0
ファイル: test_parseutils.py プロジェクト: n-someya/pgcli
def test_simple_select_single_table_double_quoted():
    tables = extract_tables('select * from "Abc"')
    assert tables == [(None, 'Abc', None)]
コード例 #21
0
def test_simple_insert_single_table():
    tables = extract_tables('insert into abc (id, name) values (1, "def")')

    # sqlparse mistakenly assigns an alias to the table
    # assert tables == [(None, 'abc', None)]
    assert tables == [(None, 'abc', 'abc')]
コード例 #22
0
ファイル: test_parseutils.py プロジェクト: n-someya/pgcli
def test_simple_select_multiple_tables_double_quoted():
    tables = extract_tables('select * from "Abc", "Def"')
    assert tables == [(None, 'Abc', None), (None, 'Def', None)]
コード例 #23
0
def test_join_table(join_type):
    sql = 'SELECT * FROM abc a {0} JOIN def d ON a.id = d.num'.format(
        join_type)
    tables = extract_tables(sql)
    assert sorted(tables) == [(None, 'abc', 'a'), (None, 'def', 'd')]
コード例 #24
0
ファイル: test_parseutils.py プロジェクト: n-someya/pgcli
def test_simple_select_single_table_deouble_quoted_aliased():
    tables = extract_tables('select * from "Abc" a')
    assert tables == [(None, 'Abc', 'a')]
コード例 #25
0
def test_simple_select_with_cols_multiple_tables():
    tables = extract_tables('select a,b from abc, def')
    assert sorted(tables) == [(None, 'abc', None), (None, 'def', None)]
コード例 #26
0
ファイル: test_parseutils.py プロジェクト: n-someya/pgcli
def test_simple_select_multiple_tables_deouble_quoted_aliased():
    tables = extract_tables('select * from "Abc" a, "Def" d')
    assert tables == [(None, 'Abc', 'a'), (None, 'Def', 'd')]
コード例 #27
0
def test_select_with_hanging_comma_multiple_tables():
    tables = extract_tables('select a, from abc, def')
    assert sorted(tables) == [(None, 'abc', None), (None, 'def', None)]
コード例 #28
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_schema_qualified_function_as_table(arg_list):
    tables = extract_tables('SELECT * FROM foo.bar({0})'.format(arg_list))
    assert tables == [('foo', 'bar', None, True)]
コード例 #29
0
def test_simple_aliased_function_as_table(arg_list):
    tables = extract_tables('SELECT * FROM foo({0}) bar'.format(arg_list))
    assert tables == [(None, 'foo', 'bar', True)]
コード例 #30
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_select_single_table_schema_qualified():
    tables = extract_tables('select * from abc.def')
    assert tables == [('abc', 'def', None, False)]
コード例 #31
0
def test_simple_select_with_cols_single_table_schema_qualified():
    tables = extract_tables('select a,b from abc.def')
    assert tables == [('abc', 'def', None)]
コード例 #32
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_aliased_function_as_table(arg_list):
    tables = extract_tables('SELECT * FROM foo({0}) bar'.format(arg_list))
    assert tables == [(None, 'foo', 'bar', True)]
コード例 #33
0
def test_simple_select_with_cols_multiple_tables():
    tables = extract_tables('select a,b from abc.def, def.ghi')
    assert sorted(tables) == [('abc', 'def', None), ('def', 'ghi', None)]
コード例 #34
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_table_and_function():
    tables = extract_tables('SELECT * FROM foo JOIN bar()')
    assert tables == [(None, 'foo', None, False), (None, 'bar', None, True)]
コード例 #35
0
def test_select_with_hanging_comma_single_table():
    tables = extract_tables('select a, from abc')
    assert tables == [(None, 'abc', None)]
コード例 #36
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_complex_table_and_function():
    tables = extract_tables('''SELECT * FROM foo.bar baz
                               JOIN bar.qux(x, y, z) quux''')
    assert tables == [('foo', 'bar', 'baz', False),
                      ('bar', 'qux', 'quux', True)]
コード例 #37
0
def test_select_with_hanging_period_multiple_tables():
    tables = extract_tables('SELECT t1. FROM tabl1 t1, tabl2 t2')
    assert sorted(tables) == [(None, 'tabl1', 't1'), (None, 'tabl2', 't2')]
コード例 #38
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_select_single_table_double_quoted():
    tables = extract_tables('select * from "Abc"')
    assert tables == [(None, 'Abc', None, False)]
コード例 #39
0
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)]
コード例 #40
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_select_multiple_tables():
    tables = extract_tables('select * from abc, def')
    assert sorted(tables) == [(None, 'abc', None, False),
                              (None, 'def', None, False)]
コード例 #41
0
def test_simple_update_table():
    tables = extract_tables('update abc.def set id = 1')
    assert tables == [('abc', 'def', None)]
コード例 #42
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_select_multiple_tables_double_quoted():
    tables = extract_tables('select * from "Abc", "Def"')
    assert tables == [(None, 'Abc', None, False), (None, 'Def', None, False)]
コード例 #43
0
def test_join_table_schema_qualified():
    tables = extract_tables(
        'SELECT * FROM abc.def x JOIN ghi.jkl y ON x.id = y.num')
    assert tables == [('abc', 'def', 'x'), ('ghi', 'jkl', 'y')]
コード例 #44
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_select_single_table_deouble_quoted_aliased():
    tables = extract_tables('select * from "Abc" a')
    assert tables == [(None, 'Abc', 'a', False)]
コード例 #45
0
def test_simple_select_with_cols_single_table_schema_qualified():
    tables = extract_tables('select a,b from abc.def')
    assert tables == [('abc', 'def', None)]
コード例 #46
0
ファイル: test_parseutils.py プロジェクト: mdsrosa/pgcli
def test_simple_select_multiple_tables_deouble_quoted_aliased():
    tables = extract_tables('select * from "Abc" a, "Def" d')
    assert tables == [(None, 'Abc', 'a', False), (None, 'Def', 'd', False)]
コード例 #47
0
def test_simple_select_with_cols_multiple_tables():
    tables = extract_tables('select a,b from abc.def, def.ghi')
    assert sorted(tables) == [('abc', 'def', None), ('def', 'ghi', None)]
コード例 #48
0
def test_simple_update_table():
    tables = extract_tables('update abc set id = 1')
    assert tables == [(None, 'abc', None)]
コード例 #49
0
def test_select_with_hanging_comma_single_table():
    tables = extract_tables('select a, from abc')
    assert tables == [(None, 'abc', None)]
コード例 #50
0
def test_join_table(join_type):
    sql = 'SELECT * FROM abc a {0} JOIN def d ON a.id = d.num'.format(join_type)
    tables = extract_tables(sql)
    assert sorted(tables) == [(None, 'abc', 'a'), (None, 'def', 'd')]
コード例 #51
0
def test_select_with_hanging_period_multiple_tables():
    tables = extract_tables('SELECT t1. FROM tabl1 t1, tabl2 t2')
    assert sorted(tables) == [(None, 'tabl1', 't1'), (None, 'tabl2', 't2')]
コード例 #52
0
def test_simple_select_single_table():
    tables = extract_tables('select * from abc')
    assert tables == [(None, 'abc', None)]
コード例 #53
0
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)]
コード例 #54
0
def test_simple_schema_qualified_function_as_table(arg_list):
    tables = extract_tables('SELECT * FROM foo.bar({0})'.format(arg_list))
    assert tables == [('foo', 'bar', None, True)]
コード例 #55
0
def test_simple_update_table():
    tables = extract_tables('update abc.def set id = 1')
    assert tables == [('abc', 'def', None)]
コード例 #56
0
def test_join_as_table():
    tables = extract_tables('SELECT * FROM my_table AS m WHERE m.a > 5')
    assert tables == [(None, 'my_table', 'm')]
コード例 #57
0
def test_join_table_schema_qualified():
    tables = extract_tables('SELECT * FROM abc.def x JOIN ghi.jkl y ON x.id = y.num')
    assert tables == [('abc', 'def', 'x'), ('ghi', 'jkl', 'y')]
コード例 #58
0
def test_simple_select_multiple_tables_schema_qualified():
    tables = extract_tables('select * from abc.def, ghi.jkl')
    assert sorted(tables) == [('abc', 'def', None), ('ghi', 'jkl', None)]
コード例 #59
0
def test_join_as_table():
    tables = extract_tables('SELECT * FROM my_table AS m WHERE m.a > 5')
    assert tables == [(None, 'my_table', 'm')]
コード例 #60
0
def test_simple_select_with_cols_single_table():
    tables = extract_tables('select a,b from abc')
    assert tables == [(None, 'abc', None)]