The error is complaining about the backref ("on relation
Royalty.owner"), so it makes sense that it would go away if you remove
the backref.

The error says that you need to specify foreign_keys for the backref,
so you should try that. i.e, change
 backref='owner'
to
 backref=backref('owner', foreign_keys = [owners_table.c.owner_id])


On Fri, Jun 12, 2009 at 12:31 PM, Affect<[email protected]> wrote:
>
> Hello:
>
> When I use the foreign_keys argument to the relation function in the
> mapper of SA, I get the following error:
>
> ArgumentError: Could not determine relation direction for primaryjoin
> condition 'drm_owners.owner_id = drm_contract_royalties.contract_id',
> on relation Royalty.owner. Specify the 'foreign_keys' argument to
> indicate which columns on the relation are foreign.
>
> This error only shows when the 'backref' argument is specified and not
> otherwise! Is this a bug in alchemy or am I missing something?
>
> Here's the mapper conf:
> ===================
> mapper(Royalty, royalties_table)
> mapper(Owner, owners_table,
>        properties = {
>            'works': relation(Work, backref='owner'),
>            'royalty': relation(Royalty,
>
> primaryjoin=owners_table.c.owner_id==royalties_table.c.contract_id,
>                foreign_keys=[royalties_table.c.contract_id],
>                backref='owner')
>            })
>
> So, if I remove the 'backref' argument from the call to 'relation',
> the relation works, but of course I lose the backref 'owner'.
>
> Thanks!
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to