I should learn to explain better what "syncrules" are about, so heres
an attempt:

when you have a table A and a table B, and then a mapping relationship
between A and B, theres a join condition set up between the two tables.
 By default, it draws from the foreign keys of the tables.
Alternatively, you can send "primaryjoin" and optionally
"secondaryjoin" (if you have a secondary association table in the
middle) to specify this join condition manually.

Lets take a join condition of A.a_id=B.a_id.   That means when I create
an instance mapped to table "A", it will have a primary key attribute
"a_id".  An instance mapped to table "B" will have an attribute "a_id"
as well which contains the id of its related "A" object.

The syncrule generated for this relationship is then "after saving an
instance of "A", copy the value of its "a_id" attribute to the "a_id"
attribute on all the "B" elements attached to it".  The syncrule is
generated in the sqlalchemy.orm.sync module, and traverses across the
join conditions (i.e. the "primaryjoin") in order to generate the rule.

If the syncrules execute and dont manage to find any rules that map
attributes from "A" to "B", its clear that the mapper has no way of
relating in the database the "A"/"B" relationship.  So for now, it
assumes that its an error.  Since if you have made a relation() from A
to B, the mapper needs to be able to persist it.

So when you get that error message, it means the join conditions are
not taking into account the two tables involved in such a way that the
syncrules can figure it out, usually because the two tables are related
via an intermediary table which is stuck in the middle of the join (it
doesnt handle that).

The syncrules are only needed for saving objects, not loading them,
which is why I added the "viewonly" flag to relations in case you
really want a relation() that uses an unusual join, and you dont care
about the mapper being able to persist it.


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