only those paths, i.e. and not 'x.y.x'; eagerload('children.children')
applies only to exactly two-levels deep, etc. [ticket:777]
+ - query doesn't throw an error if you use distinct() and an order_by()
+ containing UnaryExpressions (or other) together [ticket:848]
+
- The session API has been solidified:
- It's an error to session.save() an object which is already
# for a DISTINCT query, you need the columns explicitly specified in order
# to use it in "order_by". ensure they are in the column criterion (particularly oid).
- # TODO: this should be done at the SQL level not the mapper level
- # TODO: need test coverage for this
if self._distinct and order_by:
- [statement.append_column(c) for c in util.to_list(order_by)]
+ order_by = [expression._literal_as_text(o) for o in util.to_list(order_by) or []]
+ cf = sql_util.ColumnFinder()
+ for o in order_by:
+ cf.traverse(o)
+
+ [statement.append_column(c) for c in cf]
context.statement = statement
assert 2 == create_session().query(User).filter(users.c.name.endswith('ed')).count()
+class DistinctTest(QueryTest):
+ def test_basic(self):
+ assert [User(id=7), User(id=8), User(id=9),User(id=10)] == create_session().query(User).distinct().all()
+ assert [User(id=7), User(id=9), User(id=8),User(id=10)] == create_session().query(User).distinct().order_by(desc(User.name)).all()
+
+
class TextTest(QueryTest):
def test_fulltext(self):
assert [User(id=7), User(id=8), User(id=9),User(id=10)] == create_session().query(User).from_statement("select * from users").all()