diff options
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r-- | test/dialect/postgresql/test_reflection.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py index 70bc26e0b..b30cb506b 100644 --- a/test/dialect/postgresql/test_reflection.py +++ b/test/dialect/postgresql/test_reflection.py @@ -74,6 +74,51 @@ class ForeignTableReflectionTest(fixtures.TablesTest, AssertsExecutionResults): eq_(names, ['testtable']) +class PartitionedReflectionTest( + fixtures.TablesTest, AssertsExecutionResults): + # partitioned table reflection, issue #4237 + + __only_on__ = 'postgresql >= 10' + __backend__ = True + + @classmethod + def define_tables(cls, metadata): + # the actual function isn't reflected yet + dv = Table( + 'data_values', metadata, + Column('modulus', Integer, nullable=False), + Column('data', String(30)), + postgresql_partition_by='range(modulus)') + + # looks like this is reflected prior to #4237 + sa.event.listen( + dv, + "after_create", + sa.DDL( + "CREATE TABLE data_values_4_10 PARTITION OF data_values " + "FOR VALUES FROM (4) TO (10)") + ) + + def test_get_tablenames(self): + assert {'data_values', 'data_values_4_10'}.issubset( + inspect(testing.db).get_table_names() + ) + + def test_reflect_cols(self): + cols = inspect(testing.db).get_columns('data_values') + eq_( + [c['name'] for c in cols], + ['modulus', 'data'] + ) + + def test_reflect_cols_from_partition(self): + cols = inspect(testing.db).get_columns('data_values_4_10') + eq_( + [c['name'] for c in cols], + ['modulus', 'data'] + ) + + class MaterializedViewReflectionTest( fixtures.TablesTest, AssertsExecutionResults): """Test reflection on materialized views""" |