- attached polymorph2.diff
Attempts to update/insert into irrelevant tables when using a polymorphic mapper
Issue #235
resolved
I was trying the latest version of SQLAlchemy and (after some trouble with SQLite caused by the fact that my home area is on a network share), I found a problem in the new polymorphic mapper support.
Specifically, with a set-up like
pjoin = polymorphic_union({
'user': principals.join(users),
'group': principals.join(groups),
'principal': principals,
}, 'type', 'pjoin')
and {{{User}}}, {{{Group}}} and {{{Principal}}} classes with the obvious inheritance relationships, it's possible that creating a new {{{User}}} object will cause SQLAlchemy to attempt to insert into {{{groups}}} table(!)
This fails in my case because I have attributes on {{{Group}}} objects (and in the {{{groups}}} table) that are set to {{{nullable=False}}} and don't correspond to any attribute in the {{{users}}} table.
Comments (2)
-
Account Deleted -
repo owner - changed status to invalid
we've worked this out in email, was a small user error
- Log in to comment
A test case plus a proposed fix for the problem.