joined table inheritance doesn't work with non-matching attribute names
Issue #2344
resolved
Hi SQLALchemy-Team,
I can't use joined table inheritance with non-matching attributes. See attached files which just differ in lines 16, 25, and 36. If that is a feature and not a bug, line 25 should not be necessary in the "match"-case (file 'test_ok.py'). I tested it with version 0.7.4
Cheers, Philipp
Comments (2)
-
repo owner -
repo owner - changed status to wontfix
OK assuming you got this working, email on the list or ticket if you have further problems thanks !
- Log in to comment
This isn't a bug in my view, you're attempting to flush an
EmailaddressAlias
object without a primary key.alias_emailaddress
is not the primary key of the object,Emailaddress.emailaddress
is. From http://www.sqlalchemy.org/docs/orm/inheritance.html#joined-table-inheritance:The reason the PK from the ORM point of view is from the "base" table only is because it's the only part of the PK that is common to all subclasses. It's the PK from the SQL point of view because the base table is the "non-referencing" part of the condition - it's the PK without the foreign key that gets populated, the FK referencing it then gets a copy of that primary value.
so this works:
or the other one you had.
Line 25 in test_ok.py is necessary due to an entirely different issue, which is that your
EmailaddressAlias
class has two foreign keys toEmailaddress
, so the inherit condition cannot be assumed. If the FK is non-ambiguous then you don't need it:So far I'd be looking to resolve as "worksforme".