Skip to content

Commit 4440147

Browse files
committed
Lookup usernames case insensitively
1 parent e91ff20 commit 4440147

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- no-transaction
2+
-- Copyright 2025 New Vector Ltd.
3+
--
4+
-- SPDX-License-Identifier: AGPL-3.0-only
5+
-- Please see LICENSE in the repository root for full details.
6+
7+
-- Create an index on the username column, lower-cased, so that we can lookup
8+
-- usernames in a case-insensitive manner.
9+
CREATE INDEX CONCURRENTLY IF NOT EXISTS users_lower_username_idx
10+
ON users (LOWER(username));

crates/storage-pg/src/user/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl UserRepository for PgUserRepository<'_> {
175175
, deactivated_at
176176
, can_request_admin
177177
FROM users
178-
WHERE username = $1
178+
WHERE LOWER(username) = LOWER($1)
179179
"#,
180180
username,
181181
)

0 commit comments

Comments
 (0)