diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-20 18:03:28 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-20 18:03:28 -0400 |
| commit | bd56485f4c156e9c5ffc911d9119803b1de3789f (patch) | |
| tree | b32b7b5539084638b1f0a5ffce55f5a7c5367a6c /test/sql | |
| parent | 42bbb7163adaaa1513c7c4f5212675632be8e030 (diff) | |
| download | sqlalchemy-bd56485f4c156e9c5ffc911d9119803b1de3789f.tar.gz | |
- The :paramref:`.Column.nullable` flag is implicitly set to ``False``
when that :class:`.Column` is referred to in an explicit
:class:`.PrimaryKeyConstraint` for that table. This behavior now
matches that of when the :class:`.Column` itself has the
:paramref:`.Column.primary_key` flag set to ``True``, which is
intended to be an exactly equivalent case.
fixes #3023
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_metadata.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index c078babff..02d8e65ed 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1053,6 +1053,24 @@ class TableTest(fixtures.TestBase, AssertsCompiledSQL): ) eq_(list(t.primary_key), [t.c.b, t.c.c]) + def test_pk_always_flips_nullable(self): + m = MetaData() + + t1 = Table('t1', m, Column('x', Integer), PrimaryKeyConstraint('x')) + + t2 = Table('t2', m, Column('x', Integer, primary_key=True)) + + eq_(list(t1.primary_key), [t1.c.x]) + + eq_(list(t2.primary_key), [t2.c.x]) + + assert t1.c.x.primary_key + assert t2.c.x.primary_key + + assert not t2.c.x.nullable + assert not t1.c.x.nullable + + class SchemaTypeTest(fixtures.TestBase): class MyType(sqltypes.SchemaType, sqltypes.TypeEngine): column = None |
