From c9125a9efd1beb0f5406568ef05eaeb2b544c00a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 21 Sep 2010 10:11:10 -0400 Subject: - Patched a case where query.join() would adapt the right side to the right side of the left's join inappropriately [ticket:1925] --- lib/sqlalchemy/sql/util.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/sqlalchemy/sql') 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. -- cgit v1.2.1