def test_join_functions_on_suggests_columns_and_join_conditions(completer): text = '''SELECT * FROM set_returning_func() f1 INNER JOIN set_returning_func() f2 ON f1.''' result = result_set(completer, text) assert result == set( [name_join('y = f2.y'), name_join('x = f2.x')] + testdata.columns('set_returning_func', typ='functions'))
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') ])
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') ])
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_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"') ]
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') ])