summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-05-07 12:52:25 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-05-07 12:52:25 -0400
commit4bc2402cc0bc585af1d0e7d59000f73cf20cf452 (patch)
treebc753ce330385f31c870ad5ecc4230e899967599 /lib/sqlalchemy/sql/util.py
parent7adcb1c7443265fc99d05714c964c795f0fe1c13 (diff)
downloadsqlalchemy-4bc2402cc0bc585af1d0e7d59000f73cf20cf452.tar.gz
- Changed the handling in determination of join
conditions such that foreign key errors are only considered between the two given tables. That is, t1.join(t2) will report FK errors that involve 't1' or 't2', but anything involving 't3' will be skipped. This affects join(), as well as ORM relationship and inherit condition logic. Will keep the more conservative approach to [ticket:2153] in 0.6.
Diffstat (limited to 'lib/sqlalchemy/sql/util.py')
-rw-r--r--lib/sqlalchemy/sql/util.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index 853ec9c5f..1a3f7d2f8 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -187,7 +187,6 @@ def adapt_criterion_to_null(crit, nulls):
return visitors.cloned_traverse(crit, {}, {'binary':visit_binary})
-
def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None):
"""create a join condition between two tables or selectables.
@@ -203,11 +202,9 @@ def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None):
between the two selectables. If there are multiple ways
to join, or no way to join, an error is raised.
- :param ignore_nonexistent_tables: This flag will cause the
- function to silently skip over foreign key resolution errors
- due to nonexistent tables - the assumption is that these
- tables have not yet been defined within an initialization process
- and are not significant to the operation.
+ :param ignore_nonexistent_tables: Deprecated - this
+ flag is no longer used. Only resolution errors regarding
+ the two given tables are propagated.
:param a_subset: An optional expression that is a sub-component
of ``a``. An attempt will be made to join to just this sub-component
@@ -228,11 +225,11 @@ def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None):
key=lambda fk:fk.parent._creation_order):
try:
col = fk.get_referent(left)
- except exc.NoReferencedTableError:
- if ignore_nonexistent_tables:
- continue
- else:
+ except exc.NoReferenceError, nrte:
+ if nrte.table_name == left.name:
raise
+ else:
+ continue
if col is not None:
crit.append(col == fk.parent)
@@ -243,11 +240,13 @@ def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None):
key=lambda fk:fk.parent._creation_order):
try:
col = fk.get_referent(b)
- except exc.NoReferencedTableError:
- if ignore_nonexistent_tables:
- continue
- else:
+ except exc.NoReferenceError, nrte:
+ if nrte.table_name == b.name:
raise
+ else:
+ # this is totally covered. can't get
+ # coverage to mark it.
+ continue
if col is not None:
crit.append(col == fk.parent)