Skip to content

Conversation

@jestrada51
Copy link

Changes / Features implemented

Updated solution from the previous pull request #2966

Added a database migration that adds collations to the auth_user username field so username lookups within the API endpoints become case-insensitive.

Added a regression test (TestCaseInsensitiveUserQuery) that confirms /api/v1/profiles.json?users= correctly matches users regardless of casing (bob, Bob, bOb, etc.).

Steps taken to verify this change does what is intended

Manual verification of the migration was done to ensure that the collation was properly added
Manual verification of the API endpoints in curl was done in accordance to the example in the original #2803 post to ensure correct behavior
Test case was ran with different variants of the target username in order to make sure applying the collation leads for case insensitivity.

Side effects of implementing this change

Api endpoints such as:

    /api/v1/profiles.json?users=<username>

and

 /api/v1/profiles/<username>/

are now case insensitive

Before submitting this PR for review, please make sure you have:

  • Included tests
  • Updated documentation

Joel Estrada added 2 commits December 10, 2025 01:53
…h allows for case insensitivity for the username property in api endpoints
… Current Migration satisfies the username case insensitivity for the API endpoints
@FrankApiyo
Copy link
Member

@jestrada51 Kindly check on the Static Code Analysis issues flagged by Codacy, and also make sure your commits are signed.

You can learn about signing your commits here: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@kelvin-muchiri
Copy link
Contributor

kelvin-muchiri commented Dec 10, 2025

@jestrada51 Kindly make the following changes:

  1. Viewsets in DRF is a class based view that holds logic for different endpoints. Adding a onadata/apps/api/tests/viewsets/test_case_insensitive_username_viewset.py implies there exists a viewset called case_insensitive_username_viewset which is not the case. The tests you've added are best suited to live on this file onadata/apps/api/tests/viewsets/test_user_viewset.py
  2. Rebase your branch with main branch
  3. Sign your commits
  4. Address any lint errors raised by the CI runners e.g Codacy Static Code Analysis. To make it easier for all contributors, we use pre-commit hooks to automatically format code before commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants