summaryrefslogtreecommitdiff
path: root/test/engine
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-01-20 17:55:01 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-01-20 18:06:18 -0500
commit49f1807f8f2acea5494fa77d217dce813a933147 (patch)
tree1d0e96e90604ee24ff250fd57b3a73d1d2b209ec /test/engine
parent44cba66cb2eb4411b43c228c4f1191c764607855 (diff)
downloadsqlalchemy-49f1807f8f2acea5494fa77d217dce813a933147.tar.gz
- simplify the mechanics of PrimaryKeyConstraint with regards to reflection;
reflection now updates the PKC in place. - support the use case of the empty PrimaryKeyConstraint in order to specify constraint options; the columns marked as primary_key=True will now be gathered into the columns collection, rather than being ignored. [ticket:2910] - add validation such that column specification should only take place in the PrimaryKeyConstraint directly, or by using primary_key=True flags; if both are present, they have to match exactly, otherwise the condition is assumed to be ambiguous, and a warning is emitted; the old behavior of using the PKC columns only is maintained.
Diffstat (limited to 'test/engine')
-rw-r--r--test/engine/test_reflection.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py
index bd065103e..2f311f7e7 100644
--- a/test/engine/test_reflection.py
+++ b/test/engine/test_reflection.py
@@ -361,6 +361,27 @@ class ReflectionTest(fixtures.TestBase, ComparesTables):
self.assert_(isinstance(table.c.col4.type, sa.String))
@testing.provide_metadata
+ def test_override_upgrade_pk_flag(self):
+ meta = self.metadata
+ table = Table(
+ 'override_test', meta,
+ Column('col1', sa.Integer),
+ Column('col2', sa.String(20)),
+ Column('col3', sa.Numeric)
+ )
+ table.create()
+
+ meta2 = MetaData(testing.db)
+ table = Table(
+ 'override_test', meta2,
+ Column('col1', sa.Integer, primary_key=True),
+ autoload=True)
+
+ eq_(list(table.primary_key), [table.c.col1])
+ eq_(table.c.col1.primary_key, True)
+
+
+ @testing.provide_metadata
def test_override_pkfk(self):
"""test that you can override columns which contain foreign keys
to other reflected tables, where the foreign key column is also