MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_order_by_label

Method test_order_by_label

test/sql/test_query.py:75–112  ·  view source on GitHub ↗

test that a label within an ORDER BY works on each backend. This test should be modified to support [ticket:1068] when that ticket is implemented. For now, you need to put the actual string in the ORDER BY.

(self, connection)

Source from the content-addressed store, hash-verified

73 )
74
75 def test_order_by_label(self, connection):
76 """test that a label within an ORDER BY works on each backend.
77
78 This test should be modified to support [ticket:1068] when that ticket
79 is implemented. For now, you need to put the actual string in the
80 ORDER BY.
81
82 """
83
84 users = self.tables.users
85
86 connection.execute(
87 users.insert(),
88 [
89 {"user_id": 7, "user_name": "jack"},
90 {"user_id": 8, "user_name": "ed"},
91 {"user_id": 9, "user_name": "fred"},
92 ],
93 )
94
95 concat = ("test: " + users.c.user_name).label("thedata")
96 eq_(
97 connection.execute(select(concat).order_by("thedata")).fetchall(),
98 [("test: ed",), ("test: fred",), ("test: jack",)],
99 )
100
101 eq_(
102 connection.execute(select(concat).order_by("thedata")).fetchall(),
103 [("test: ed",), ("test: fred",), ("test: jack",)],
104 )
105
106 concat = ("test: " + users.c.user_name).label("thedata")
107 eq_(
108 connection.execute(
109 select(concat).order_by(desc("thedata"))
110 ).fetchall(),
111 [("test: jack",), ("test: fred",), ("test: ed",)],
112 )
113
114 @testing.requires.order_by_label_with_expression
115 def test_order_by_label_compound(self, connection):

Callers

nothing calls this directly

Calls 8

eq_Function · 0.90
selectFunction · 0.90
descFunction · 0.90
executeMethod · 0.45
insertMethod · 0.45
labelMethod · 0.45
fetchallMethod · 0.45
order_byMethod · 0.45

Tested by

no test coverage detected