Opened 14 years ago

Closed 13 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: no UI/UX: no

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 by k0001, 13 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: invalid
Status: newclosed

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