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:31:53 -0400 |
| commit | 6ec2246d04e3608a024b1425207c80c73fa78218 (patch) | |
| tree | 8fc4b962afaf82b63311206a49660ff9c64e3f07 /lib/sqlalchemy | |
| parent | 7a1c19833eac79ada3ef624cae656f6f5a76cfdd (diff) | |
| download | sqlalchemy-6ec2246d04e3608a024b1425207c80c73fa78218.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
(cherry picked from commit 3ed79a5c18c14d842280805d1dae8a9c99ec8f18)
Diffstat (limited to 'lib/sqlalchemy')
| -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 8ce44b936..f2b708f9f 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: |
