mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: ignore case while sorting usernames (#7870)
This commit is contained in:
@@ -933,7 +933,7 @@ func (q *fakeQuerier) GetUsers(_ context.Context, params database.GetUsersParams
|
||||
|
||||
// Database orders by username
|
||||
slices.SortFunc(users, func(a, b database.User) bool {
|
||||
return a.Username < b.Username
|
||||
return strings.ToLower(a.Username) < strings.ToLower(b.Username)
|
||||
})
|
||||
|
||||
// Filter out deleted since they should never be returned..
|
||||
|
||||
@@ -4779,9 +4779,9 @@ WHERE
|
||||
-- The pagination cursor is the last ID of the previous page.
|
||||
-- The query is ordered by the username field, so select all
|
||||
-- rows after the cursor.
|
||||
(username) > (
|
||||
(LOWER(username)) > (
|
||||
SELECT
|
||||
username
|
||||
LOWER(username)
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
@@ -4818,7 +4818,7 @@ WHERE
|
||||
-- End of filters
|
||||
ORDER BY
|
||||
-- Deterministic and consistent ordering of all users. This is to ensure consistent pagination.
|
||||
username ASC OFFSET $5
|
||||
LOWER(username) ASC OFFSET $5
|
||||
LIMIT
|
||||
-- A null limit means "no limit", so 0 means return all
|
||||
NULLIF($6 :: int, 0)
|
||||
|
||||
@@ -145,9 +145,9 @@ WHERE
|
||||
-- The pagination cursor is the last ID of the previous page.
|
||||
-- The query is ordered by the username field, so select all
|
||||
-- rows after the cursor.
|
||||
(username) > (
|
||||
(LOWER(username)) > (
|
||||
SELECT
|
||||
username
|
||||
LOWER(username)
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
@@ -184,7 +184,7 @@ WHERE
|
||||
-- End of filters
|
||||
ORDER BY
|
||||
-- Deterministic and consistent ordering of all users. This is to ensure consistent pagination.
|
||||
username ASC OFFSET @offset_opt
|
||||
LOWER(username) ASC OFFSET @offset_opt
|
||||
LIMIT
|
||||
-- A null limit means "no limit", so 0 means return all
|
||||
NULLIF(@limit_opt :: int, 0);
|
||||
|
||||
Reference in New Issue
Block a user