diff options
Diffstat (limited to 'test/dialect/oracle/test_reflection.py')
| -rw-r--r-- | test/dialect/oracle/test_reflection.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/test/dialect/oracle/test_reflection.py b/test/dialect/oracle/test_reflection.py index 3d1361adb..97fb627f9 100644 --- a/test/dialect/oracle/test_reflection.py +++ b/test/dialect/oracle/test_reflection.py @@ -533,6 +533,83 @@ class RoundTripIndexTest(fixtures.TestBase): __backend__ = True @testing.provide_metadata + def test_no_pk(self): + metadata = self.metadata + + Table( + "sometable", + metadata, + Column("id_a", Unicode(255)), + Column("id_b", Unicode(255)), + Index("pk_idx_1", "id_a", "id_b", unique=True), + Index("pk_idx_2", "id_b", "id_a", unique=True), + ) + metadata.create_all() + + insp = inspect(testing.db) + eq_( + insp.get_indexes("sometable"), + [ + { + "name": "pk_idx_1", + "column_names": ["id_a", "id_b"], + "dialect_options": {}, + "unique": True, + }, + { + "name": "pk_idx_2", + "column_names": ["id_b", "id_a"], + "dialect_options": {}, + "unique": True, + }, + ], + ) + + @testing.combinations((True,), (False,)) + @testing.provide_metadata + def test_include_indexes_resembling_pk(self, explicit_pk): + metadata = self.metadata + + t = Table( + "sometable", + metadata, + Column("id_a", Unicode(255), primary_key=True), + Column("id_b", Unicode(255), primary_key=True), + Column("group", Unicode(255), primary_key=True), + Column("col", Unicode(255)), + # Oracle won't let you do this unless the indexes have + # the columns in different order + Index("pk_idx_1", "id_b", "id_a", "group", unique=True), + Index("pk_idx_2", "id_b", "group", "id_a", unique=True), + ) + if explicit_pk: + t.append_constraint( + PrimaryKeyConstraint( + "id_a", "id_b", "group", name="some_primary_key" + ) + ) + metadata.create_all() + + insp = inspect(testing.db) + eq_( + insp.get_indexes("sometable"), + [ + { + "name": "pk_idx_1", + "column_names": ["id_b", "id_a", "group"], + "dialect_options": {}, + "unique": True, + }, + { + "name": "pk_idx_2", + "column_names": ["id_b", "group", "id_a"], + "dialect_options": {}, + "unique": True, + }, + ], + ) + + @testing.provide_metadata def test_basic(self): metadata = self.metadata @@ -560,8 +637,10 @@ class RoundTripIndexTest(fixtures.TestBase): ) metadata.create_all() + mirror = MetaData(testing.db) mirror.reflect() + metadata.drop_all() mirror.create_all() |
