--- a/hooks/syncschema.py Thu Aug 26 11:45:57 2010 +0200
+++ b/hooks/syncschema.py Mon Sep 06 15:03:11 2010 +0200
@@ -519,10 +519,16 @@
insert_rdef_on_subclasses(session, eschema, rschema, rdefdef,
{'composite': entity.composite})
else:
+ if rschema.symmetric:
+ # for symmetric relations, rdefs will store relation definitions
+ # in both ways (i.e. (subj -> obj) and (obj -> subj))
+ relation_already_defined = len(rschema.rdefs) > 2
+ else:
+ relation_already_defined = len(rschema.rdefs) > 1
# need to create the relation if no relation definition in the
# schema and if it has not been added during other event of the same
# transaction
- if not (len(rschema.rdefs) > 1 or
+ if not (relation_already_defined or
rtype in session.transaction_data.get('createdtables', ())):
rschema = schema.rschema(rtype)
# create the necessary table