summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/mapping/properties.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2005-12-29 00:42:00 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2005-12-29 00:42:00 +0000
commitaded80c2ae63a2a89c09c0d75d2a8320f97edae3 (patch)
treec89e6e6604c514c27981304cb8b14a9d2ed4d260 /lib/sqlalchemy/mapping/properties.py
parent38cb94232e22b07fd139bb68be8d6e3b8e566fb9 (diff)
downloadsqlalchemy-aded80c2ae63a2a89c09c0d75d2a8320f97edae3.tar.gz
moved _match_primaries from properties to sql.join, so its generalized to all SQL
Diffstat (limited to 'lib/sqlalchemy/mapping/properties.py')
-rw-r--r--lib/sqlalchemy/mapping/properties.py23
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py
index cd04c0c64..ba7312c12 100644
--- a/lib/sqlalchemy/mapping/properties.py
+++ b/lib/sqlalchemy/mapping/properties.py
@@ -174,12 +174,12 @@ class PropertyLoader(MapperProperty):
# if join conditions were not specified, figure them out based on foreign keys
if self.secondary is not None:
if self.secondaryjoin is None:
- self.secondaryjoin = self._match_primaries(self.target, self.secondary)
+ self.secondaryjoin = sql.join(self.target, self.secondary).onclause
if self.primaryjoin is None:
- self.primaryjoin = self._match_primaries(parent.table, self.secondary)
+ self.primaryjoin = sql.join(parent.table, self.secondary).onclause
else:
if self.primaryjoin is None:
- self.primaryjoin = self._match_primaries(parent.table, self.target)
+ self.primaryjoin = sql.join(parent.table, self.target).onclause
# if the foreign key wasnt specified and theres no assocaition table, try to figure
# out who is dependent on who. we dont need all the foreign keys represented in the join,
@@ -268,23 +268,6 @@ class PropertyLoader(MapperProperty):
else:
return dependent[0]
- def _match_primaries(self, primary, secondary):
- crit = []
- for fk in secondary.foreign_keys:
- if fk.references(primary):
- crit.append(primary._get_col_by_original(fk.column) == fk.parent)
- self.foreignkey = fk.parent
- for fk in primary.foreign_keys:
- if fk.references(secondary):
- crit.append(secondary._get_col_by_original(fk.column) == fk.parent)
- self.foreignkey = fk.parent
- if len(crit) == 0:
- raise "Cant find any foreign key relationships between '%s' (%s) and '%s' (%s)" % (primary.name, repr(primary), secondary.name, repr(secondary))
- elif len(crit) == 1:
- return (crit[0])
- else:
- return sql.and_(*crit)
-
def _compile_synchronizers(self):
def compile(binary):
if binary.operator != '=' or not isinstance(binary.left, schema.Column) or not isinstance(binary.right, schema.Column):