def test_suggested_join_conditions(completer, text):
    result = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set([
        alias('users'),
        alias('shipments'),
        name_join('shipments.id = users.id'),
        fk_join('shipments.user_id = users.id')])
Esempio n. 2
0
def test_suggested_aliases_after_on_right_side(completer, complete_event):
    text = 'SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON x.id = '
    position = len(text)
    result = set(
        completer.get_completions(
            Document(text=text, cursor_position=position), complete_event))
    assert set(result) == set([alias('x'), alias('y')])
Esempio n. 3
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 = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_set(
        [alias("users"), alias("orders")])
def test_suggested_join_conditions(completer, complete_event, text):
    result = set(completer.get_completions(
        Document(text=text,), complete_event))
    assert set(result) == set([
        alias('U'),
        alias('U2'),
        fk_join('U2.userid = U.id')])
Esempio n. 5
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')])
def test_cased_join_conditions(cased_completer, complete_event, text):
    result = set(cased_completer.get_completions(
        Document(text=text), complete_event))
    assert set(result) == set([
        alias('U'),
        alias('U2'),
        fk_join('U2.UserID = U.ID')])
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 = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_set(
        [alias('u'), alias('o')])
def test_suggested_aliases_after_on(completer, text):
    position = len('SELECT u.name, o.id FROM users u JOIN orders o ON ')
    result = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_set([
        alias('u'),
        name_join('o.id = u.id'),
        name_join('o.email = u.email'),
        alias('o')])
def test_suggested_join_conditions_with_invalid_table(completer,
                                                      complete_event, text,
                                                      ref):
    position = len(text)
    result = set(
        completer.get_completions(
            Document(text=text, cursor_position=position), complete_event))
    assert set(result) == set([alias('users'), alias(ref)])
def test_suggested_tables_after_on_right_side(completer, complete_event, text):
    position = len('SELECT users.name, orders.id FROM users JOIN orders ON orders.user_id = ')
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([
        alias('users'),
        alias('orders')])
def test_suggested_tables_after_on_right_side(completer, complete_event, text):
    position = len(
        'SELECT users.name, orders.id FROM users JOIN orders ON orders.user_id = '
    )
    result = set(
        completer.get_completions(
            Document(text=text, cursor_position=position), complete_event))
    assert set(result) == set([alias('users'), alias('orders')])
Esempio n. 12
0
def test_suggested_join_conditions(completer, text):
    result = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set([
        alias("users"),
        alias("shipments"),
        name_join("shipments.id = users.id"),
        fk_join("shipments.user_id = users.id"),
    ])
Esempio n. 13
0
def test_suggested_aliases_after_on(completer, text):
    position = len("SELECT u.name, o.id FROM users u JOIN orders o ON ")
    result = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_set([
        alias("u"),
        name_join("o.id = u.id"),
        name_join("o.email = u.email"),
        alias("o"),
    ])
Esempio n. 14
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')])
def test_suggested_join_conditions(completer, complete_event, text):
    position = len(text)
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([
        alias('u'),
        alias('u2'),
        fk_join('u2.userid = u.id')])
def test_suggested_aliases_after_on_right_side(completer, complete_event):
    text = 'SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON x.id = '
    position = len(text)
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([
        alias('x'),
        alias('y')])
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 = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_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')])
def test_suggested_tables_after_on(completer, text):
    position = len('SELECT users.name, orders.id FROM users JOIN orders ON ')
    result = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_set([
        name_join('orders.id = users.id'),
        name_join('orders.email = users.email'),
        alias('users'),
        alias('orders')
    ])
def test_suggested_tables_after_on(completer, complete_event, text):
    position = len('SELECT users.name, orders.id FROM users JOIN orders ON ')
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([
        name_join('orders.id = users.id'),
        name_join('orders.email = users.email'),
        alias('users'),
        alias('orders')])
def test_suggested_join_conditions(completer, complete_event, text):
    position = len(text)
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([
        alias('users'),
        alias('shipments'),
        name_join('shipments.id = users.id'),
        fk_join('shipments.user_id = users.id')])
def test_suggested_tables_after_on(completer, complete_event, text):
    position = len('SELECT users.name, orders.id FROM users JOIN orders ON ')
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([
        name_join('orders.id = users.id'),
        name_join('orders.email = users.email'),
        alias('users'),
        alias('orders')])
def test_suggestions_after_on(completer, complete_event, text):
    position = len('SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON ')
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(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')])
def test_suggestions_after_on(completer, complete_event, text):
    position = len('SELECT x.id, y.product_name FROM custom.products x JOIN custom.products y ON ')
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(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')])
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"')
    ]
Esempio n. 25
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 = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_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"),
    ])
def test_suggested_join_conditions_with_same_table_twice(completer, complete_event, text):
    position = len(text)
    result = completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event)
    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('"Users"'),
        alias('u'),
        alias('u2'),
        alias('users')]
def test_suggested_join_conditions_with_same_table_twice(
        completer, complete_event, text):
    position = len(text)
    result = completer.get_completions(
        Document(text=text, cursor_position=position), complete_event)
    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"')
    ]
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')
    ])
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')]
    )
def test_suggested_join_conditions_with_invalid_table(completer, text, ref):
    result = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set(
        [alias('users'), alias(ref)])
def test_cased_join_conditions(completer, text):
    result = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set(
        [alias('U'), alias('U2'), fk_join('U2.UserID = U.ID')]
    )
def test_suggested_join_conditions_with_invalid_table(completer, text, ref):
    result = result_set(completer, text)
    assert result == set([alias('users'), alias(ref)])
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')])
def test_suggested_join_conditions_with_invalid_table(completer, complete_event, text, ref):
    position = len(text)
    result = set(completer.get_completions(
        Document(text=text, cursor_position=position),
        complete_event))
    assert set(result) == set([alias('users'), alias(ref)])
Esempio n. 35
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 = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set(
        [alias("x"), alias("y")])
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')]
    )
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 = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set(
        [alias('x'), alias('y')])
def test_suggested_join_conditions_with_invalid_table(completer, text, ref):
    result = result_set(completer, text)
    assert result == set([alias('users'), alias(ref)])
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 = get_result(completer, text, position)
    assert completions_to_set(result) == completions_to_set(
        [alias('users'), alias('orders')])
def test_suggested_join_conditions(completer, text):
    result = get_result(completer, text)
    assert completions_to_set(result) == completions_to_set([
        alias('U'), alias('U2'), fk_join('U2.userid = U.id')
    ])
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')
    ])
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')])