MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_order_by_custom

Method test_order_by_custom

test/orm/test_composites.py:1959–1987  ·  view source on GitHub ↗

test #12769

(self)

Source from the content-addressed store, hash-verified

1957 )
1958
1959 def test_order_by_custom(self):
1960 """test #12769"""
1961 self._fixture(True)
1962 Edge = self.classes.Edge
1963 s = fixture_session()
1964
1965 self.assert_compile(
1966 s.query(Edge).order_by(Edge.start.desc()),
1967 "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
1968 "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
1969 "FROM edge "
1970 "ORDER BY edge.x1 DESC, edge.y1 ASC",
1971 )
1972
1973 self.assert_compile(
1974 s.query(Edge).order_by(Edge.start.desc().nulls_first()),
1975 "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
1976 "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
1977 "FROM edge "
1978 "ORDER BY edge.x1 DESC NULLS FIRST, edge.y1 ASC NULLS FIRST",
1979 )
1980
1981 self.assert_compile(
1982 s.query(Edge).order_by(desc(Edge.start)),
1983 "SELECT edge.id AS edge_id, edge.x1 AS edge_x1, "
1984 "edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 "
1985 "FROM edge "
1986 "ORDER BY edge.x1 DESC, edge.y1 ASC",
1987 )
1988
1989 def test_order_by_aliased(self):
1990 self._fixture(False)

Callers

nothing calls this directly

Calls 8

_fixtureMethod · 0.95
fixture_sessionFunction · 0.90
descFunction · 0.90
assert_compileMethod · 0.80
order_byMethod · 0.45
queryMethod · 0.45
descMethod · 0.45
nulls_firstMethod · 0.45

Tested by

no test coverage detected