コード例 #1
0
def test_suggested_join_conditions(completer, text):
    result = result_set(completer, text)
    assert result == set([
        alias('users'),
        alias('shipments'),
        name_join('shipments.id = users.id'),
        fk_join('shipments.user_id = users.id')
    ])
コード例 #2
0
def test_suggested_aliases_after_on(completer, text):
    position = len('SELECT u.name, o.id FROM users u JOIN orders o ON ')
    result = result_set(completer, text, position)
    assert result == set([
        alias('u'),
        name_join('o.id = u.id'),
        name_join('o.email = u.email'),
        alias('o')
    ])
コード例 #3
0
def test_suggested_tables_after_on(completer, text):
    position = len('SELECT users.name, orders.id FROM users JOIN orders ON ')
    result = result_set(completer, text, position)
    assert result == set([
        name_join('orders.id = users.id'),
        name_join('orders.email = users.email'),
        alias('users'),
        alias('orders')
    ])
コード例 #4
0
def test_suggestions_after_on(completer, text):
    position = len(
        'SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON '
    )
    result = result_set(completer, text, position)
    assert result == set([
        alias('x'),
        alias('y'),
        name_join('y.price = x.price'),
        name_join('y.product_name = x.product_name'),
        name_join('y.id = x.id')
    ])
コード例 #5
0
def test_suggested_join_conditions_with_same_table_twice(completer, text):
    result = get_result(completer, text)
    assert result == [
        fk_join('u2.userid = u.id'),
        fk_join('u2.userid = users.id'),
        name_join('u2.userid = "Users".userid'),
        name_join('u2.username = "******".username'),
        alias('u'),
        alias('u2'),
        alias('users'),
        alias('"Users"')
    ]
コード例 #6
0
def test_suggested_aliases_after_on_right_side(completer):
    text = 'SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON x.id = '
    result = result_set(completer, text)
    assert result == set([alias('x'), alias('y')])
コード例 #7
0
def test_suggested_tables_after_on_right_side(completer, text):
    position = len(
        'SELECT users.name, orders.id FROM users JOIN orders ON orders.user_id = '
    )
    result = result_set(completer, text, position)
    assert result == set([alias('users'), alias('orders')])
コード例 #8
0
def test_suggested_aliases_after_on_right_side(completer, text):
    position = len(
        'SELECT u.name, o.id FROM users u JOIN orders o ON o.user_id = ')
    result = result_set(completer, text, position)
    assert result == set([alias('u'), alias('o')])
コード例 #9
0
def test_suggested_join_conditions_with_invalid_table(completer, text, ref):
    result = result_set(completer, text)
    assert result == set([alias('users'), alias(ref)])
コード例 #10
0
def test_cased_join_conditions(completer, text):
    result = result_set(completer, text)
    assert result == set(
        [alias('U'), alias('U2'),
         fk_join('U2.UserID = U.ID')])
コード例 #11
0
def test_suggested_join_conditions(completer, text):
    result = result_set(completer, text)
    assert result == set(
        [alias('U'), alias('U2'),
         fk_join('U2.userid = U.id')])