diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-09 16:54:47 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-09 16:54:47 +0000 |
commit | c1d5cdb94092a4ca54c837a2ce272eea85f22de9 (patch) | |
tree | fd9c2ddfa1f201859eded3f7425b9012373b66ce /lib/sqlalchemy | |
parent | 476d395f5e4e5ec37e0fb72cb5d0cd0b0e429a80 (diff) | |
download | sqlalchemy-c1d5cdb94092a4ca54c837a2ce272eea85f22de9.tar.gz |
more searching for equiv columns
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index aaff05028..f523d0706 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -521,14 +521,24 @@ class Mapper(object): # TODO: matching of cols to foreign keys might better be generalized # into general column translation (i.e. corresponding_column) + + # recursively descend into the foreign key collection of the given column + # and assemble each FK-related col as an "equivalent" for the given column + def equivs(col, recursive, equiv): + if col in recursive: + return + recursive.add(col) + for fk in col.foreign_keys: + result.setdefault(fk.column, util.Set()).add(equiv) + equivs(fk.column, recursive, col) + for column in (self.primary_key_argument or self.pks_by_table[self.mapped_table]): for col in column.proxy_set: if not col.foreign_keys: result.setdefault(col, util.Set()).add(col) else: - for fk in col.foreign_keys: - result.setdefault(fk.column, util.Set()).add(col) - + equivs(col, util.Set(), col) + return result class _CompileOnAttr(PropComparator): |