Opened 4 years ago

Closed 4 years ago

#14564 closed (invalid)

case insensitive unique_together

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Should it be possible to specify a case insensitive match for unique-together fields? I have a field I'm using for abbreviations of index terms in a library catalogue, and it would be helpful to constrain new additions to be unique without regard to case.

replicate -

  1. Create a model with a slugfield
  2. Add a unique_together constraint on it
  3. Add items with field set to "A" and "a" without an error (although obviously sometime this is the desired behaviour)

Change History (1)

comment:1 Changed 4 years ago by k0001

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The various values on the unique_together option map directly to the UNIQUE constraint of backend databases, so the behavior of unique_together depends on this; no manual comparisons are done for the values in the columns.

Your problem could be solved by always storing either lowercase or uppercase values in your unique_together-constrained column.

Note: See TracTickets for help on using tickets.
Back to Top