Skip to content

Fix: Apply case-sensitive filter in uniqueness validation#7470

Merged
Gitesh307 merged 9 commits into
mainfrom
issue-4058-1
Oct 28, 2025
Merged

Fix: Apply case-sensitive filter in uniqueness validation#7470
Gitesh307 merged 9 commits into
mainfrom
issue-4058-1

Conversation

@Gitesh307
Copy link
Copy Markdown
Contributor

@Gitesh307 Gitesh307 commented Oct 2, 2025

Fixes #4058

This PR addresses the case sensitivity discrepancy between frontend and backend uniqueness rules. Previously, the frontend enforced case-sensitive uniqueness, but the backend validation raised exceptions due to case-insensitive checks. The implementation has been updated so that backend uniqueness validation now uses case-sensitive matching (BINARY comparison) on string fields, while preserving the original behavior for related lookups and non-string fields. This brings the backend into alignment with the frontend, ensuring consistent validation across the application.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone

Testing instructions

  • Define a uniqueness rule on a text field (e.g., remarks) in Uniqueness Rules.
  • Create a record (e.g., Accession) with a text value, e.g., abc.
  • Create another record with the same text in different case, e.g., aBc.
  • Verify: the record is created successfully without any uniqueness error.
  • Verify that unique fields (e.g., username) correctly block case-sensitive duplicates on the frontend by showing a validation warning instead of allowing submission and throwing a backend BusinessRuleException.

Copy link
Copy Markdown
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

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

  • Define a uniqueness rule on a text field (e.g., remarks) in Uniqueness Rules.
  • Create a record (e.g., Accession) with a text value, e.g., abc.
  • Create another record with the same text in different case, e.g., aBc.
  • Verify: the record is created successfully without any uniqueness error.

Looks good, I tried with a few different text fields and I didn't run into any issues.

@emenslin emenslin requested a review from a team October 3, 2025 16:40
Copy link
Copy Markdown
Collaborator

@lexiclevenger lexiclevenger left a comment

Choose a reason for hiding this comment

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

  • Define a uniqueness rule on a text field (e.g., remarks) in Uniqueness Rules.
  • Create a record (e.g., Accession) with a text value, e.g., abc.
  • Create another record with the same text in different case, e.g., aBc.
  • Verify: the record is created successfully without any uniqueness error.
  • Verify that unique fields (e.g., username) correctly block case-sensitive duplicates on the frontend by showing a validation warning instead of allowing submission and throwing a backend BusinessRuleException.

Looks good! No error occurs when unique fields have the same text with different cases

Copy link
Copy Markdown
Contributor

@melton-jason melton-jason left a comment

Choose a reason for hiding this comment

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

Nice work! 👏 🚀

Nothing major in my comments, primarily just refactoring/code maintainability suggestions.

Comment thread specifyweb/backend/businessrules/uniqueness_rules.py Outdated
Comment thread specifyweb/backend/businessrules/uniqueness_rules.py
Comment thread specifyweb/frontend/js_src/lib/components/DataModel/businessRules.ts Outdated
@Gitesh307 Gitesh307 requested review from a team October 14, 2025 14:15
Copy link
Copy Markdown
Contributor

@melton-jason melton-jason left a comment

Choose a reason for hiding this comment

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

Nice work!

@Gitesh307 Gitesh307 merged commit 16156e0 into main Oct 28, 2025
14 checks passed
@Gitesh307 Gitesh307 deleted the issue-4058-1 branch October 28, 2025 18:30
@github-project-automation github-project-automation Bot moved this from 📋Back Log to ✅Done in General Tester Board Oct 28, 2025
@Gitesh307 Gitesh307 self-assigned this Nov 6, 2025
melton-jason added a commit that referenced this pull request May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅Done

Development

Successfully merging this pull request may close these issues.

Case sensitivity discrepancy between front/backend uniqueness rules

6 participants