def test_aliased_joins(self, completer, text): result = result_set(completer, text) self.assertSetEqual(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(self, completer, text): result = result_set(completer, text) self.assertSetEqual(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_suggested_joins(self, completer, text): result = result_set(completer, text) self.assertSetEqual(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_suggested_joins_quoted_schema_qualified_table( self, completer, text): result = result_set(completer, text) self.assertSetEqual( result, set(testdata.schemas_and_from_clause_items() + [join('public.users ON users.id = "Users".userid')]))
def test_join_alias_search_without_aliases1(self, completer): text = 'SELECT * FROM blog.Entries JOIN blog.e' result = get_result(completer, text) self.assertListEqual(result[:2], [ table('Entries', -1), join('EntAccLog ON EntAccLog.EntryID = Entries.EntryID', -1) ])
def test_suggested_joins(self, completer, query, tbl): result = result_set(completer, query.format(tbl)) self.assertSetEqual( result, set(TESTDATA.schemas_and_from_clause_items() + [ join('custom.shipments ON shipments.user_id = {0}.id'.format( tbl)) ]))
def test_suggested_joins_fuzzy(self, completer, text): result = result_set(completer, text) last_word = text.split()[-1] expected = join('users ON users.id = u.userid', -len(last_word)) self.assertTrue(expected in result)
def test_join_alias_search_without_aliases2(self, completer): text = 'SELECT * FROM blog.Entries JOIN blog.et' result = get_result(completer, text) self.assertEqual( result[0], join('EntryTags ON EntryTags.EntryID = Entries.EntryID', -2))