basically the "foreignkey" property was originally meant as a way to
"fool" the relationship into reversing the the direction of a
one-to-many self referential relationship, and is mostly an internal
variable used to figure out the "direction" of a relationship in other
cases.  in fact in the case of a many-to-many relationship the
"foreignkey" property is completely ignored at the moment.

it was not originally written to be used the way you are using it; i.e.
when your Table has no ForeignKey objects on it.  however, that is what
it should be doing going forward.

i tried to see what would be involved to get it to work that way, but
besides creating potentially backwards-incompatible behavior with some
people's self-referential code, it also is not a trivial change as
there are some tricky things to take into account with more complicated
relationships.  As the usage of "foreignkey" is now deprecated for
self-referential relationships in favor of the new "remote_side"
argument, i think i will instead just add a totally new argument
"foreign_keys", which is used strictly as a guide as to what columns on
the tables contain foreign key relationships, so that "foreignkey" and
its various internal usage can just fade away without being messed
with.  I have added ticket 385 for this, and in fact i think if it
truly is a list of the foreign keys for the Table, it should be on the
Mapper, not the relation.

as for "viewonly", also going on in all your examples is that the
various flags are not being propigated to the backreference (i.e.
viewonly, foreignkey) so thats failing also.  i have committed in r2128
the ability for the backref to pick up on the parent's "viewonly" flag
without you having to specify an explicit backref (note that an explcit
backref means you say, backref=backref('foo', primaryjoin=x..) etc).

so for now, dont rely on "foreignkey" at all, and for the backrefs
either dont use "viewonly", write out the backrefs explcitly, or use
the revision 2128 or greater of the trunk.


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to