]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add a test to confirm alter table of pk column gets reflected
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Oct 2011 16:30:23 +0000 (12:30 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Oct 2011 16:30:23 +0000 (12:30 -0400)
test/dialect/test_postgresql.py

index 8f90becd59541a0bd6ab09a4f8dba577b1c738af..b37344b279e23e3e0945308dd8812dfeb485202d 100644 (file)
@@ -1316,6 +1316,17 @@ class ReflectionTest(fixtures.TestBase):
         r = t3.insert().execute()
         eq_(r.inserted_primary_key, [2])
 
+    @testing.provide_metadata
+    def test_renamed_pk_reflection(self):
+        metadata = self.metadata
+        t = Table('t', metadata, Column('id', Integer, primary_key=True))
+        metadata.create_all()
+        testing.db.connect().execution_options(autocommit=True).\
+            execute('alter table t rename id to t_id')
+        m2 = MetaData(testing.db)
+        t2 = Table('t', m2, autoload=True)
+        eq_([c.name for c in t2.primary_key], ['t_id'])
+
     @testing.provide_metadata
     def test_schema_reflection(self):
         """note: this test requires that the 'test_schema' schema be