Skip to content

Commit

Permalink
[phoenix] get_view_names() returning empty list (#2889)
Browse files Browse the repository at this point in the history
  • Loading branch information
agl29 committed Jun 17, 2022
1 parent 878a4bf commit 2901e0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def get_table_names(self, connection, schema=None, order_by=None, **kw):
def get_view_names(self, connection, schema=None, **kw):
if schema is None:
schema = ''
return connection.connect().connection.meta().get_tables(schemaPattern=schema,
typeList=('VIEW'))
views = connection.connect().connection.meta().get_tables(schemaPattern=schema, typeList=('VIEW',))
return [view['TABLE_NAME'] for view in views]

def get_columns(self, connection, table_name, schema=None, **kw):
if schema is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_schema_filtering(self):
connection.execute(text('create table ALCHEMY_TEST (ID integer primary key)'))
connection.execute(text('create table A.ALCHEMY_TEST_A (ID_A integer primary key)'))
connection.execute(text('create table B.ALCHEMY_TEST_B (ID_B integer primary key)'))
connection.execute(text('create view ALCHEMY_TEST_VIEW as select * from ALCHEMY_TEST'))

self.assertEqual(inspector.get_schema_names(), ['', 'A', 'B', 'SYSTEM'])

Expand All @@ -76,6 +77,8 @@ def test_schema_filtering(self):
self.assertEqual(inspector.get_table_names('A'), ['ALCHEMY_TEST_A'])
self.assertEqual(inspector.get_table_names('B'), ['ALCHEMY_TEST_B'])

self.assertEqual(inspector.get_view_names(), ['ALCHEMY_TEST_VIEW'])

self.assertEqual(inspector.get_columns('ALCHEMY_TEST').pop()['name'], 'ID')
self.assertEqual(
inspector.get_columns('ALCHEMY_TEST', '').pop()['name'], 'ID')
Expand All @@ -87,6 +90,7 @@ def test_schema_filtering(self):
self.assertTrue(engine.has_table('ALCHEMY_TEST_A', 'A'))
self.assertFalse(engine.has_table('ALCHEMY_TEST', 'A'))
finally:
connection.execute('drop view if exists ALCHEMY_TEST_VIEW')
connection.execute('drop table if exists ALCHEMY_TEST')
connection.execute('drop table if exists A.ALCHEMY_TEST_A')
connection.execute('drop table if exists B.ALCHEMY_TEST_B')
Expand Down

0 comments on commit 2901e0d

Please sign in to comment.