Adrian wrote:
>
> in my case it must be something different. The following code works
> perfectly fine in 0.5.2:
>
> mapper(Contact, CONTACTS)
>
> mapper(Atom, ATOMS,
>     properties = {
>         'Contacts': relation(Contact,
>                         primaryjoin = Contact.atom_id==ATOMS.c.id,
>                         foreign_keys = [Contact.atom_id], lazy=True,
> uselist=True, viewonly=True,
>                         backref = backref('Atom', primaryjoin =
> Contact.atom_id==ATOMS.c.id,
>                                             foreign_keys =
> [ATOMS.c.id],
>                                             lazy=True, uselist=False,
> viewonly=True)
>                         )
>     })
>
> In: atom = session.query(Atom).filter(Atom.id==57).one()
>
> In: atom.Contacts
> Out: [<Contact(57, 9)>]
>
> In 0.5.3 however, the backref() will throw the following error:
>
> ArgumentError: Atom.Contacts and back-reference Contact.Atom are both
> of the same direction <symbol 'ONETOMANY>.  Did you mean to set
> remote_side on the many-to-one side ?
>
> Any ideas?

in this case you have set the foreign_keys collection backwards on the
backref.  the foreign key is always contact.atom_id.  its also not needed
if you have ForeignKey objects on your table metadata.


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

Reply via email to