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