On Apr 24, 2012, at 5:59 PM, David Bowser wrote: > > On Apr 24, 2012, at 5:50 PM, Michael Bayer <[email protected]> wrote: > >> one-to-many is defined as parent->child where child has a foreign key column >> referring to parent; many-to-one is the reverse, where parent has a foreign >> key that refers to child. When you tell the ORM "foreign_keys = >> [some_col_on_parent]", that tells SQLA that the parent refers to the child, >> hence many-to-one, hence uselist is set to False. > > > My apologies for not being precise. > > I stated in the original message that the warning is occurring when using the > backref. So it defines many entries -> one profile fine, but when I used the > backref it still had uselist set to False.
UserMixin.user_id -> JournalEntry.id , foreign key is established as JournalEntry.id via the "foreign_keys" argument which propagates by default to the backref, so UserMixin.user_profile evaluates as one-to-many, hence uselist=True, JournalEntry.journal_entries evaluates as many-to-one, hence uselist=False. If you enable INFO logging for the "sqlalchemy.orm" logger, it will output the "direction" that it picks up on for all relationships. -- 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.
