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)
| 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): |