|
12 | 12 | from scim2_models import default_comparison_key |
13 | 13 | from scim2_server.utils import load_default_service_provider_config |
14 | 14 | from sqlalchemy import select |
| 15 | +from sqlalchemy import text |
15 | 16 | from sqlalchemy.dialects import mysql |
16 | 17 |
|
17 | 18 | from scim2_sqlalchemy.comparison import _comparator |
@@ -228,3 +229,28 @@ def test_postgresql_approaches_the_default_key(session, database_url, value): |
228 | 229 | assert session.scalar(select(expression)) == default_comparison_key( |
229 | 230 | column.binding, value |
230 | 231 | ) |
| 232 | + |
| 233 | + |
| 234 | +@pytest.mark.parametrize( |
| 235 | + ("parameters", "expected"), |
| 236 | + [ |
| 237 | + ({"sort_by": "userName"}, ["e", "f", "é"]), |
| 238 | + ({"filter": 'userName lt "f"'}, ["e"]), |
| 239 | + ], |
| 240 | +) |
| 241 | +def test_postgresql_orders_strings_by_code_point( |
| 242 | + sync_storage_factory, session, database_url, user_type, parameters, expected |
| 243 | +): |
| 244 | + """The order of scim2-models holds whatever the collation of the column.""" |
| 245 | + if database_url.startswith("sqlite"): |
| 246 | + pytest.skip("SQLite orders strings by code point") |
| 247 | + session.execute( |
| 248 | + text( |
| 249 | + 'ALTER TABLE users ALTER COLUMN user_name TYPE varchar COLLATE "und-x-icu"' |
| 250 | + ) |
| 251 | + ) |
| 252 | + storage = sync_storage_factory() |
| 253 | + for name in ("é", "f", "e"): |
| 254 | + storage.create(user_type, UserModel(user_name=name)) |
| 255 | + |
| 256 | + assert user_names(storage, user_type, **parameters) == expected |
0 commit comments