summaryrefslogtreecommitdiff
path: root/examples/nested_sets
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-11-03 02:52:30 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-11-03 02:52:30 +0000
commita5dfbeedb9f7ae148081d1dbc3e91e876526eb90 (patch)
tree070cede0b9a927c5672a7b847113a9947a2726ce /examples/nested_sets
parent334d5118bb7bcf6fcf052c1b12182009fe54ebef (diff)
downloadsqlalchemy-a5dfbeedb9f7ae148081d1dbc3e91e876526eb90.tar.gz
- Improved the behavior of aliased() objects such that they more
accurately adapt the expressions generated, which helps particularly with self-referential comparisons. [ticket:1171] - Fixed bug involving primaryjoin/secondaryjoin conditions constructed from class-bound attributes (as often occurs when using declarative), which later would be inappropriately aliased by Query, particularly with the various EXISTS based comparators.
Diffstat (limited to 'examples/nested_sets')
-rw-r--r--examples/nested_sets/nested_sets.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/nested_sets/nested_sets.py b/examples/nested_sets/nested_sets.py
index 8af9aed45..e83a263e9 100644
--- a/examples/nested_sets/nested_sets.py
+++ b/examples/nested_sets/nested_sets.py
@@ -84,10 +84,9 @@ session.commit()
print session.query(Employee).all()
# 1. Find an employee and all his/her supervisors, no matter how deep the tree.
-# (the between() operator in SQLAlchemy has a bug here, [ticket:1171])
ealias = aliased(Employee)
print session.query(Employee).\
- filter(ealias.left>=Employee.left).filter(ealias.left<=Employee.right).\
+ filter(ealias.left.between(Employee.left, Employee.right)).\
filter(ealias.emp=='Eddie').all()
#2. Find the employee and all his/her subordinates. (This query has a nice symmetry with the first query.)
@@ -97,7 +96,7 @@ print session.query(Employee).\
#3. Find the level of each node, so you can print the tree as an indented listing.
for indentation, employee in session.query(func.count(Employee.emp).label('indentation') - 1, ealias).\
- filter(ealias.left>=Employee.left).filter(ealias.left<=Employee.right).\
+ filter(ealias.left.between(Employee.left, Employee.right)).\
group_by(ealias.emp).\
order_by(ealias.left):
print " " * indentation + str(employee)