diff options
| author | Tom Manderson <me@trm.io> | 2018-10-30 13:05:43 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-10-30 13:21:52 -0400 |
| commit | 3ed79a5c18c14d842280805d1dae8a9c99ec8f18 (patch) | |
| tree | 5af38fc2c1c488a6b95e7ee360937204a5c46ed2 /lib/sqlalchemy/ext | |
| parent | f041f1d198689cc6bc0a52377e5d50dcc07a29f0 (diff) | |
| download | sqlalchemy-3ed79a5c18c14d842280805d1dae8a9c99ec8f18.tar.gz | |
Move pk on single-inh subclass check below conflict resolution check
The column conflict resolution technique discussed at
:ref:`declarative_column_conflicts` is now functional for a :class:`.Column`
that is also a primary key column. Previously, a check for primary key
columns declared on a single-inheritance subclass would occur before the
column copy were allowed to pass.
Fixes: #4352
Change-Id: Id4c025da53c28e58db6b549fe398f25f8a90d355
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/483
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/declarative/base.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/sqlalchemy/ext/declarative/base.py b/lib/sqlalchemy/ext/declarative/base.py index a6642364d..e5bc670b3 100644 --- a/lib/sqlalchemy/ext/declarative/base.py +++ b/lib/sqlalchemy/ext/declarative/base.py @@ -534,11 +534,6 @@ class _MapperConfig(object): ) # add any columns declared here to the inherited table. for c in declared_columns: - if c.primary_key: - raise exc.ArgumentError( - "Can't place primary key columns on an inherited " - "class with no table." - ) if c.name in inherited_table.c: if inherited_table.c[c.name] is c: continue @@ -547,6 +542,11 @@ class _MapperConfig(object): "existing column '%s'" % (c, cls, inherited_table.c[c.name]) ) + if c.primary_key: + raise exc.ArgumentError( + "Can't place primary key columns on an inherited " + "class with no table." + ) inherited_table.append_column(c) if inherited_mapped_table is not None and \ inherited_mapped_table is not inherited_table: |
