diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-09 00:24:15 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-09 00:24:15 +0000 |
commit | b5060e88ff4604af4c9e51003a078dbb59fce968 (patch) | |
tree | 539fe14f93a268875e1ea4717c50dbaaf3c66e90 /lib/sqlalchemy/mapping/properties.py | |
parent | f057ed6136fe5583d4174a55153544783e76699a (diff) | |
download | sqlalchemy-b5060e88ff4604af4c9e51003a078dbb59fce968.tar.gz |
added 'noninherited table' prop to mapper indicating the "lead" table, in the case of
inheritance. relations now create priamry/secondary joins against that lead table. if you want to create it against
an inherited table, use explicit join conditions.
added 'correlate' argument to CompoundSelect to get polymorph example working again.
Diffstat (limited to 'lib/sqlalchemy/mapping/properties.py')
-rw-r--r-- | lib/sqlalchemy/mapping/properties.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py index 805a625f3..fc6762b59 100644 --- a/lib/sqlalchemy/mapping/properties.py +++ b/lib/sqlalchemy/mapping/properties.py @@ -172,17 +172,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 = sql.join(self.target, self.secondary).onclause + self.secondaryjoin = sql.join(self.mapper.noninherited_table, self.secondary).onclause if self.primaryjoin is None: - self.primaryjoin = sql.join(parent.table, self.secondary).onclause - tf = mapper.TableFinder(self.secondaryjoin, check_columns=True) - tf2 = mapper.TableFinder(self.primaryjoin, check_columns=True) - for t in tf2: - if t is not self.secondary and t in tf: - raise ArgumentError("Ambiguous join conditions generated between '%s' and '%s' (primaryjoin='%s', secondaryjoin='%s'); please specify explicit primaryjoin and/or secondaryjoin arguments to property '%s'" % (parent.table.id, self.target.id, self.primaryjoin, self.secondaryjoin, self.key)) + self.primaryjoin = sql.join(parent.noninherited_table, self.secondary).onclause else: if self.primaryjoin is None: - self.primaryjoin = sql.join(parent.table, self.target).onclause + self.primaryjoin = sql.join(parent.noninherited_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, # just one of them. |