From: Mike Bayer Date: Fri, 3 Jun 2011 06:24:06 +0000 (-0400) Subject: hey this works. (don't need to re-calc fks collection) X-Git-Tag: rel_0_7_1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dfcbf6156abbc5a148011c93bffb734e1cf8e58;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git hey this works. (don't need to re-calc fks collection) --- diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index dc12c105db..43fb567f8b 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -1155,17 +1155,19 @@ class RelationshipProperty(StrategizedProperty): else: self.direction = MANYTOONE else: - foreign_keys = [f for (c, f) in self.synchronize_pairs] parentcols = util.column_set(self.parent.mapped_table.c) targetcols = util.column_set(self.mapper.mapped_table.c) # fk collection which suggests ONETOMANY. - onetomany_fk = targetcols.intersection(foreign_keys) + onetomany_fk = targetcols.intersection( + self._calculated_foreign_keys) # fk collection which suggests MANYTOONE. - manytoone_fk = parentcols.intersection(foreign_keys) + manytoone_fk = parentcols.intersection( + self._calculated_foreign_keys) + if not onetomany_fk and not manytoone_fk: raise sa_exc.ArgumentError("Can't determine relationshi" "p direction for relationship '%s' - foreign "