def test_aliased_joins(completer, text): result = result_set(completer, text) assert result == set(testdata.schemas() + aliased_rels + [ join('"Users" U ON U.userid = Users.id'), join('users u ON u.id = Users.parentid'), join('users u ON u.parentid = Users.id'), ])
def test_cased_joins(completer, text): result = result_set(completer, text) assert result == set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_cased_joins(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_suggested_joins(completer, text): result = result_set(completer, text) assert result == set(testdata.schemas_and_from_clause_items() + [ join('"Users" ON "Users".userid = Users.id'), join('users users2 ON users2.id = Users.parentid'), join('users users2 ON users2.parentid = Users.id'), ])
def test_aliased_joins(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set(testdata.schemas() + aliased_rels + [ join('"Users" U ON U.userid = Users.id'), join('users u ON u.id = Users.parentid'), join('users u ON u.parentid = Users.id'), ])
def test_aliased_joins(aliased_completer, complete_event, text): result = set(aliased_completer.get_completions( Document(text=text), complete_event)) assert set(result) == set(testdata.schemas() + aliased_rels + [ join('"Users" U ON U.userid = Users.id'), join('users u ON u.id = Users.parentid'), join('users u ON u.parentid = Users.id'), ])
def test_cased_joins(cased_completer, complete_event, text): result = set(cased_completer.get_completions( Document(text=text), complete_event)) assert set(result) == set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_cased_joins(cased_completer, complete_event, text): result = set( cased_completer.get_completions(Document(text=text), complete_event)) assert set(result) == set([schema('PUBLIC')] + cased_rels + [ join('"Users" ON "Users".UserID = Users.ID'), join('Users Users2 ON Users2.ID = Users.PARENTID'), join('Users Users2 ON Users2.PARENTID = Users.ID'), ])
def test_aliased_joins(aliased_completer, complete_event, text): result = set( aliased_completer.get_completions(Document(text=text), complete_event)) assert set(result) == set(testdata.schemas() + aliased_rels + [ join('"Users" U ON U.userid = Users.id'), join('users u ON u.id = Users.parentid'), join('users u ON u.parentid = Users.id'), ])
def test_suggested_joins(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set( testdata.schemas_and_from_clause_items() + [ join('"Users" ON "Users".userid = Users.id'), join("users users2 ON users2.id = Users.parentid"), join("users users2 ON users2.parentid = Users.id"), ])
def test_suggested_joins(completer, complete_event, text): result = set(completer.get_completions( Document(text=text), complete_event)) assert set(result) == set(testdata.schemas() + testdata.tables() + testdata.views() + [ join('"Users" ON "Users".userid = Users.id'), join('users users2 ON users2.id = Users.parentid'), join('users users2 ON users2.parentid = Users.id'), ] + testdata.functions())
def test_suggested_joins(completer, complete_event, text): result = set(completer.get_completions(Document(text=text), complete_event)) assert set(result) == set( testdata.schemas() + testdata.tables() + testdata.views() + [ join('"Users" ON "Users".userid = Users.id'), join('users users2 ON users2.id = Users.parentid'), join('users users2 ON users2.parentid = Users.id'), ] + testdata.functions())
def test_suggested_joins(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set( testdata.schemas_and_from_clause_items() + [ join('"Users" ON "Users".userid = Users.id'), join('users users2 ON users2.id = Users.parentid'), join('users users2 ON users2.parentid = Users.id'), ] )
def test_join_alias_search_with_aliases1(completer): text = "SELECT * FROM blog.Entries E JOIN blog.e" result = get_result(completer, text) assert result[:2] == [ table("Entries E2", -1), join("EntAccLog EAL ON EAL.EntryID = E.EntryID", -1), ]
def test_join_alias_search_without_aliases2(completer_with_casing, complete_event): text = 'SELECT * FROM blog.Entries JOIN blog.et' result = completer_with_casing.get_completions( Document(text=text), complete_event) assert result[0] == join( 'EntryTags ON EntryTags.EntryID = Entries.EntryID', -2)
def test_join_alias_search_without_aliases1(completer): text = 'SELECT * FROM blog.Entries JOIN blog.e' result = get_result(completer, text) assert result[:2] == [ table('Entries', -1), join('EntAccLog ON EntAccLog.EntryID = Entries.EntryID', -1) ]
def test_join_alias_search_without_aliases1(completer_with_casing, complete_event): text = 'SELECT * FROM blog.Entries JOIN blog.e' result = completer_with_casing.get_completions( Document(text=text), complete_event) assert result[:2] == [table('Entries', -1), join( 'EntAccLog ON EntAccLog.EntryID = Entries.EntryID', -1)]
def test_suggested_joins_fuzzy(completer, complete_event, text): position = len(text) result = set( completer.get_completions( Document(text=text, cursor_position=position), complete_event)) last_word = text.split()[-1] expected = join('users ON users.id = u.userid', -len(last_word)) assert expected in result
def test_suggested_joins_fuzzy(completer, complete_event, text): position = len(text) result = set(completer.get_completions( Document(text=text, cursor_position=position), complete_event)) last_word = text.split()[-1] expected = join('users ON users.id = u.userid', -len(last_word)) assert expected in result
def test_suggested_joins_quoted_schema_qualified_table(completer, complete_event, text): position = len(text) result = set(completer.get_completions( Document(text=text, cursor_position=position), complete_event)) assert set(result) == set(testdata.schemas() + testdata.tables() + testdata.views() + [ join('public.users ON users.id = "Users".userid'), ] + testdata.functions())
def test_suggested_joins(completer, complete_event, query, tbl): text = query.format(tbl) position = len(text) result = set(completer.get_completions( Document(text=text, cursor_position=position), complete_event)) assert set(result) == set(testdata.schemas() + testdata.tables() + [ join('custom.shipments ON shipments.user_id = {0}.id'.format(tbl)), ] + testdata.functions())
def test_suggested_joins(completer, query, tbl): result = result_set(completer, query.format(tbl)) assert result == set( testdata.schemas_and_from_clause_items() + [join('custom.shipments ON shipments.user_id = {0}.id'.format(tbl))])
def test_join_alias_search_without_aliases2(completer): text = 'SELECT * FROM blog.Entries JOIN blog.et' result = get_result(completer, text) assert result[0] == join( 'EntryTags ON EntryTags.EntryID = Entries.EntryID', -2)
def test_suggested_joins_quoted_schema_qualified_table(completer, text): result = get_result(completer, text) assert completions_to_set(result) == completions_to_set( testdata.schemas_and_from_clause_items() + [join('public.users ON users.id = "Users".userid')] )
def test_suggested_joins(completer, query, tbl): result = get_result(completer, query.format(tbl)) assert completions_to_set(result) == completions_to_set( testdata.schemas_and_from_clause_items() + [join('custom.shipments ON shipments.user_id = {0}.id'.format(tbl))] )
def test_join_alias_search_without_aliases1(completer): text = 'SELECT * FROM blog.Entries JOIN blog.e' result = get_result(completer, text) assert result[:2] == [table('Entries', -1), join( 'EntAccLog ON EntAccLog.EntryID = Entries.EntryID', -1)]
def test_suggested_joins_fuzzy(completer, text): result = get_result(completer, text) last_word = text.split()[-1] expected = join('users ON users.id = u.userid', -len(last_word)) assert expected in result
def test_join_alias_search_with_aliases2(completer): text = "SELECT * FROM blog.Entries E JOIN blog.et" result = get_result(completer, text) assert result[0] == join("EntryTags ET ON ET.EntryID = E.EntryID", -2)
def test_suggested_joins(completer, query, tbl): result = get_result(completer, query.format(tbl)) assert completions_to_set(result) == completions_to_set( testdata.schemas_and_from_clause_items() + [join("custom.shipments ON shipments.user_id = {0}.id".format(tbl))])