summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext
diff options
context:
space:
mode:
authorTom Manderson <me@trm.io>2018-10-30 13:05:43 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-10-30 13:21:52 -0400
commit3ed79a5c18c14d842280805d1dae8a9c99ec8f18 (patch)
tree5af38fc2c1c488a6b95e7ee360937204a5c46ed2 /lib/sqlalchemy/ext
parentf041f1d198689cc6bc0a52377e5d50dcc07a29f0 (diff)
downloadsqlalchemy-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.py10
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: