Thanks for the ideas. I thought of all of the above. The one I've been using is the accessor which unions together the necessary things. My question came up when I wondered if there was some even more fundamental way to handle these forwards-backwards cases. I'm glad to know I'm already doing all I can.
On Dec 2, 3:32 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Dec 2, 2008, at 5:54 PM, Eric Ongerth wrote: > > > > > Now when I want to find out whether a Foo has a relation to another > > Foo, I have to check whether there exists any row in foo_relations > > that has the given Foo as either as "this" OR "that". Also, what if I > > need backrefs on the foo_relations mapper? The backref from 'this' > > and the backref from 'that' would both point to something called a > > foo, but they would have to be given separate labels in order ot not > > be conflicting property names -- when really, I would not want to know > > if a foo was the 'that' or the 'this' of some foo relation. > > > So ideally in a case like this, I could set an option that says the > > m:m relation is bidirectional, and that the backrefs for both foreign > > keys in the m:m table should really point to the same place (or at > > least be unioned together). > > > I have a feeling that would violate some part of the RDBMS standards, > > and I'm perfectly willing to go without or work around. This is more > > of a philosophical point for learning's sake -- what do other people > > do in such cases? > > you can.... store two rows in the association table, one for each > direction. or provide an accessor which just unions together the > forwards and backwards references between Foo objects. or make a > readonly relation() that does the appropriate "OR" logic. I might > even try combining both of those techniques somehow. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---