MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_order_by

Method test_order_by

test/orm/test_composites.py:1926–1957  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1924 assert edge_1 in near_edges and edge_2 in near_edges
1925
1926 def test_order_by(self):
1927 self._fixture(False)
1928 Edge = self.classes.Edge
1929 s = fixture_session()
1930 self.assert_compile(
1931 s.query(Edge).order_by(Edge.start, Edge.end.desc()),
1932 "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
1933 "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
1934 "FROM edge ORDER BY edge.x1, edge.y1, edge.x2 DESC, edge.y2 DESC",
1935 )
1936
1937 self.assert_compile(
1938 s.query(Edge).order_by(
1939 Edge.start.asc().nulls_first(), Edge.end.nulls_last()
1940 ),
1941 "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
1942 "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
1943 "FROM edge ORDER BY edge.x1 ASC NULLS FIRST, "
1944 "edge.y1 ASC NULLS FIRST, edge.x2 NULLS LAST, edge.y2 NULLS LAST",
1945 )
1946
1947 # Test using standalone ops syntax
1948
1949 self.assert_compile(
1950 s.query(Edge).order_by(
1951 nulls_first(asc(Edge.start)), nulls_last(Edge.end)
1952 ),
1953 "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
1954 "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
1955 "FROM edge ORDER BY edge.x1 ASC NULLS FIRST, "
1956 "edge.y1 ASC NULLS FIRST, edge.x2 NULLS LAST, edge.y2 NULLS LAST",
1957 )
1958
1959 def test_order_by_custom(self):
1960 """test #12769"""

Callers

nothing calls this directly

Calls 12

_fixtureMethod · 0.95
fixture_sessionFunction · 0.90
nulls_firstFunction · 0.90
ascFunction · 0.90
nulls_lastFunction · 0.90
assert_compileMethod · 0.80
order_byMethod · 0.45
queryMethod · 0.45
descMethod · 0.45
nulls_firstMethod · 0.45
ascMethod · 0.45
nulls_lastMethod · 0.45

Tested by

no test coverage detected