Skip to content

inconsistent behavior of nullable with PrimaryKeyConstraint #3023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlalchemy-bot opened this issue Apr 15, 2014 · 4 comments
Closed

inconsistent behavior of nullable with PrimaryKeyConstraint #3023

sqlalchemy-bot opened this issue Apr 15, 2014 · 4 comments
Labels
bug Something isn't working high priority
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

this is fairly egregious, breaks alembic as one might expect

from sqlalchemy import *

m = MetaData()

t1 = Table('t1', m, Column('x', Integer), PrimaryKeyConstraint('x'))

t2 = Table('t2', m, Column('x', Integer, primary_key=True))

assert list(t1.primary_key) == [t1.c.x]

assert 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
@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

see also https://bitbucket.org/zzzeek/alembic/issue/199/alembic-attempts-to-alter_columns-in-table where we'll try to work around this on that end as well so that this doesn't need an 0.8 backport

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

  • 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 inconsistent behavior of nullable with PrimaryKeyConstraint #3023

bd56485

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

  • 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 inconsistent behavior of nullable with PrimaryKeyConstraint #3023

ca99fca

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added high priority bug Something isn't working labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 0.9.5 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

1 participant