- Query won't fail with weakref error when a non-mapper/class
instrumented descriptor is passed, raises
"Invalid column expession".
-
+
+ - Query.group_by() properly takes into account aliasing applied
+ to the FROM clause, such as with select_from(), using
+ with_polymorphic(), or using from_self().
+
- sql
- Fixed missing _label attribute on Function object, others
when used in a select() with use_labels (such as when used
criterion = list(chain(*[_orm_columns(c) for c in criterion]))
+ criterion = [self._adapt_clause(expression._literal_as_text(o), True, True) for o in criterion]
+
if self._group_by is False:
self._group_by = criterion
else:
] == create_session().query(User).filter(User.id.in_([8,9]))._from_self().\
join('addresses').add_entity(Address).order_by(User.id, Address.id).all()
+ def test_group_by(self):
+ eq_(
+ create_session().query(Address.user_id, func.count(Address.id).label('count')).\
+ group_by(Address.user_id).order_by(Address.user_id).all(),
+ [(7, 1), (8, 3), (9, 1)]
+ )
+
+ eq_(
+ create_session().query(Address.user_id, Address.id).\
+ from_self(Address.user_id, func.count(Address.id)).\
+ group_by(Address.user_id).order_by(Address.user_id).all(),
+ [(7, 1), (8, 3), (9, 1)]
+ )
+
def test_no_eagerload(self):
"""test that eagerloads are pushed outwards and not rendered in subqueries."""