summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-09-21 10:11:10 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-09-21 10:11:10 -0400
commitc9125a9efd1beb0f5406568ef05eaeb2b544c00a (patch)
treec44f19f8d6fe541db09d9b567b474516ccb1d95f /lib/sqlalchemy/sql/util.py
parent634d54742523883316bd7768c8d2918e8410aa62 (diff)
downloadsqlalchemy-c9125a9efd1beb0f5406568ef05eaeb2b544c00a.tar.gz
- Patched a case where query.join() would adapt the
right side to the right side of the left's join inappropriately [ticket:1925]
Diffstat (limited to 'lib/sqlalchemy/sql/util.py')
-rw-r--r--lib/sqlalchemy/sql/util.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index bd4f70247..638549e12 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -92,6 +92,25 @@ def find_columns(clause):
visitors.traverse(clause, {}, {'column':cols.add})
return cols
+def clause_is_present(clause, search):
+ """Given a target clause and a second to search within, return True
+ if the target is plainly present in the search without any
+ subqueries or aliases involved.
+
+ Basically descends through Joins.
+
+ """
+
+ stack = [search]
+ while stack:
+ elem = stack.pop()
+ if clause is elem:
+ return True
+ elif isinstance(elem, expression.Join):
+ stack.extend((elem.left, elem.right))
+ return False
+
+
def bind_values(clause):
"""Return an ordered list of "bound" values in the given clause.