diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-08-03 00:28:57 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-08-03 00:28:57 +0000 |
| commit | aaefbb7e04c0b673d052c225e51749549f354f12 (patch) | |
| tree | 9ca5ae39ddc83f94567b84384bfc50672f1304f5 /lib/sqlalchemy/sql.py | |
| parent | d6a6d67b8cded2280c216c6d224852f6b8a8d79e (diff) | |
| download | sqlalchemy-aaefbb7e04c0b673d052c225e51749549f354f12.tar.gz | |
- better check for ambiguous join conditions in sql.Join; propigates to a
better error message in PropertyLoader (i.e. relation()/backref()) for when
the join condition can't be reasonably determined.
- sqlite creates ForeignKeyConstraint objects properly upon table
reflection.
Diffstat (limited to 'lib/sqlalchemy/sql.py')
| -rw-r--r-- | lib/sqlalchemy/sql.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 3650dd8b8..8ad3ced45 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -1070,17 +1070,22 @@ class Join(FromClause): return column def _match_primaries(self, primary, secondary): crit = [] + constraints = util.Set() for fk in secondary.foreign_keys: if fk.references(primary): crit.append(primary.corresponding_column(fk.column) == fk.parent) + constraints.add(fk.constraint) self.foreignkey = fk.parent if primary is not secondary: for fk in primary.foreign_keys: if fk.references(secondary): crit.append(secondary.corresponding_column(fk.column) == fk.parent) + constraints.add(fk.constraint) self.foreignkey = fk.parent if len(crit) == 0: raise exceptions.ArgumentError("Cant find any foreign key relationships between '%s' and '%s'" % (primary.name, secondary.name)) +# elif len(constraints) > 1: +# raise exceptions.ArgumentError("Cant determine join between '%s' and '%s'; tables have more than one foreign key constraint relationship between them. Please specify the 'onclause' of this join explicitly. %s" % (primary.name, secondary.name, constraints)) elif len(crit) == 1: return (crit[0]) else: |
