MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_order_by_label

Method test_order_by_label

test/sql/test_query.py:76–113  ·  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

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