Skip to content

fix: ignore case while sorting usernames #7870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Jun 6, 2023

It looks like #7838 doesn't ignore casing while sorting usernames, so this PR fixes it.

Currently:

Screenshot 2023-06-06 at 10 56 35

@mtojek mtojek self-assigned this Jun 6, 2023
@mtojek mtojek marked this pull request as ready for review June 6, 2023 10:03
@mtojek mtojek requested a review from mafredri June 6, 2023 10:03
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope not, but can we have multiple users named the same? ZeroCool, zerocool, Zerocool and zeroCool. So that we'd need to handle lower(a) == lower(b) case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fortunately: User already exists. :)

@mtojek mtojek merged commit ee45b3d into coder:main Jun 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants