Hi Jonathan,

The line you commented out from the example was either:
>
> children = relationship("Child")
>
> children = relationship("Child", back_populates="parent")
>
>
> both of those lines create an iterable list of all the Child objects on 
> the `children`
>

Neither of them would work, because

sqlalchemy.exc.AmbiguousForeignKeysError: Could not determine join 
condition between parent/child tables on relationship Parent.children - 
there are multiple foreign key paths linking the tables.  Specify the 
'foreign_keys' argument, providing a list of those columns which should be 
counted as containing a foreign key reference to the parent table.

Unfortunately, the following didn’t work either:

children = relationship("Child", foreign_keys=[oldest_child_id, 
youngest_child_id])

(Oddly enough, specifying a list with a single element *does* work.)

Off the top of my head, the simplest way to accomplish this would be to add 
> a "parent_id" column on the child table, and then create a relationship for 
> "children" that correlates the `Parent.id` to `Child.parent_id`.  
>
> That change might not work with your data model if a Child can have 
> multiple parents. 
>

 Indeed, Child does have multiple parents…

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/f548656e-75aa-4041-a505-4a272c28f9b4%40googlegroups.com.

Reply via email to