diff options
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 5 | ||||
-rw-r--r-- | test/orm/query.py | 8 |
3 files changed, 15 insertions, 4 deletions
@@ -22,7 +22,11 @@ CHANGES generation to handle placing bind params inside of functions and other expressions. (partial progress towards [ticket:610]) - + + - Fixed "concatenate tuple" bug which could occur with + Query.order_by() if clause adaption had taken place. + [ticket:1027] + - Removed an ancient assertion that mapped selectables require "alias names" - the mapper creates its own alias now if none is present. Though in this case you need to diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index ae3ace753..8996a758e 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -571,8 +571,9 @@ class Query(object): q = self.__no_statement("order_by") if self._aliases_tail: - criterion = [expression._literal_as_text(o) for o in criterion] - criterion = self._aliases_tail.adapt_list(criterion) + criterion = tuple(self._aliases_tail.adapt_list( + [expression._literal_as_text(o) for o in criterion] + )) if q._order_by is False: q._order_by = criterion diff --git a/test/orm/query.py b/test/orm/query.py index c3032182c..cdd50cb70 100644 --- a/test/orm/query.py +++ b/test/orm/query.py @@ -651,6 +651,12 @@ class JoinTest(QueryTest): sess.query(User).join([('orders', orderalias), ('items', itemalias)]).filter(orderalias.user_id==9).filter(itemalias.description=='item 4').all(), [] ) + + def test_orderby_arg_bug(self): + sess = create_session() + + # no arg error + result = sess.query(User).join('orders', aliased=True).order_by([Order.id]).reset_joinpoint().order_by(users.c.id).all() def test_aliased_classes(self): sess = create_session() @@ -741,7 +747,7 @@ class JoinTest(QueryTest): result = create_session().query(User).outerjoin(['orders', 'items'], aliased=aliased).filter_by(id=3).reset_joinpoint().outerjoin(['orders','address'], aliased=aliased).filter_by(id=1).all() assert [User(id=7, name='jack')] == result - + def test_overlap_with_aliases(self): oalias = orders.alias('oalias') |