inheritance with multiple foreign keys to the base table

75 views
Skip to first unread message

Christopher Singley

unread,
Feb 24, 2015, 6:33:24 AM2/24/15
to sqlal...@googlegroups.com
I'm using declared_attr.cascading from sqlalchemy-1.0.0dev to declare a foreign key on a subclass that also needs another separate foreign key reference to the parent table.
To let the Mapper know which column to join for the polymorphic inheritance relationship, I'm trying to pass an inherit_condition argument.

Relevant code snippet can be seen here:
https://gist.github.com/anonymous/1b24768cb714fb9c7de7

Importing this code generates this warning:
"""
SAWarning: Implicitly combining column secinfo.id with column optinfo.id under attribute 'id'.  Please configure one or more attributes for these same-named columns explicitly.
"""

...and then fails with this error:
"""
sqlalchemy.exc.ArgumentError: Mapper Mapper|OPTINFO|optinfo could not assemble any primary key columns for mapped table 'Join object on secinfo(23263120) and optinfo(19756496)'
"""

How can I configure this correctly?

Michael Bayer

unread,
Feb 24, 2015, 3:31:22 PM2/24/15
to sqlal...@googlegroups.com


Christopher Singley <ch...@singleys.com> wrote:

> I'm using declared_attr.cascading from sqlalchemy-1.0.0dev to declare a foreign key on a subclass that also needs another separate foreign key reference to the parent table.
> To let the Mapper know which column to join for the polymorphic inheritance relationship, I'm trying to pass an inherit_condition argument.
>
> Relevant code snippet can be seen here:
> https://gist.github.com/anonymous/1b24768cb714fb9c7de7

this is fixed in 3a56c4f019052c5d and your example case now succeeds.


>
> Importing this code generates this warning:
> """
> SAWarning: Implicitly combining column secinfo.id with column optinfo.id under attribute 'id'. Please configure one or more attributes for these same-named columns explicitly.
> """
>
> ...and then fails with this error:
> """
> sqlalchemy.exc.ArgumentError: Mapper Mapper|OPTINFO|optinfo could not assemble any primary key columns for mapped table 'Join object on secinfo(23263120) and optinfo(19756496)'
> """
>
> How can I configure this correctly?
>
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
> To post to this group, send email to sqlal...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

Christopher Singley

unread,
Feb 24, 2015, 6:50:01 PM2/24/15
to sqlal...@googlegroups.com
Thanks!  Working for me now.

You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/a9IyAGKzr7M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages