summaryrefslogtreecommitdiff
path: root/test/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-06-10 13:50:06 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-06-10 13:51:18 -0400
commit9dba65b381a53d0126cf4b0a153be506387f1b5c (patch)
treebff0ae003b9302049a6a1503eca51ec4e236d3c9 /test/orm
parent6d0b2f34d2b829d92e173cb5e3cb0c941586759e (diff)
downloadsqlalchemy-9dba65b381a53d0126cf4b0a153be506387f1b5c.tar.gz
Fixed bug where sending a composite attribute into :meth:`.Query.order_by`
would produce a parenthesized expression not accepted by some databases. [ticket:2754] Conflicts: doc/build/changelog/changelog_09.rst
Diffstat (limited to 'test/orm')
-rw-r--r--test/orm/test_composites.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/orm/test_composites.py b/test/orm/test_composites.py
index ed80d6105..9b582ce17 100644
--- a/test/orm/test_composites.py
+++ b/test/orm/test_composites.py
@@ -712,7 +712,9 @@ class ConfigurationTest(fixtures.MappedTest):
})
self._test_roundtrip()
-class ComparatorTest(fixtures.MappedTest):
+class ComparatorTest(fixtures.MappedTest, testing.AssertsCompiledSQL):
+ __dialect__ = 'default'
+
@classmethod
def define_tables(cls, metadata):
Table('edge', metadata,
@@ -836,4 +838,28 @@ class ComparatorTest(fixtures.MappedTest):
assert edge_1 in near_edges and edge_2 in near_edges
+ def test_order_by(self):
+ self._fixture(False)
+ Edge = self.classes.Edge
+ s = Session()
+ self.assert_compile(
+ s.query(Edge).order_by(Edge.start, Edge.end),
+ "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
+ "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
+ "FROM edge ORDER BY edge.x1, edge.y1, edge.x2, edge.y2"
+ )
+
+ def test_order_by_aliased(self):
+ self._fixture(False)
+ Edge = self.classes.Edge
+ s = Session()
+ ea = aliased(Edge)
+ self.assert_compile(
+ s.query(ea).order_by(ea.start, ea.end),
+ "SELECT edge_1.id AS edge_1_id, edge_1.x1 AS edge_1_x1, "
+ "edge_1.y1 AS edge_1_y1, edge_1.x2 AS edge_1_x2, "
+ "edge_1.y2 AS edge_1_y2 "
+ "FROM edge AS edge_1 ORDER BY edge_1.x1, edge_1.y1, "
+ "edge_1.x2, edge_1.y2"
+ )