Opened 7 years ago

Last modified 7 weeks ago

#11964 new New feature

Add the ability to use database-level CHECK CONSTRAINTS

Reported by: schinckel Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: check contsraint
Cc: dbrgn, esigra, gam_phon Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


I mentioned adding database level CHECK CONSTRAINTS in a post on django-developers.

Attached to this ticket is a patch that provides the functionality listed in the first post of this thread. This is not complete: it only allows simple constraints, and is missing a complete test suite.

Attachments (1)

check_constraints.diff (15.8 KB) - added by schinckel 7 years ago.
Contains patches against trunk that enable check constraints

Download all attachments as: .zip

Change History (13)

Changed 7 years ago by schinckel

Contains patches against trunk that enable check constraints

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Someday/Maybe

If we do this, it should be tied into the model validation framework in some way.

comment:2 Changed 6 years ago by schinckel

Agreed. The initial patch was made before the changes with model validation had hit. I will get back to this at some stage.

comment:3 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 4 years ago by dbrgn

  • Cc dbrgn added

comment:7 Changed 16 months ago by timgraham

  • Patch needs improvement set

comment:8 Changed 13 months ago by esigra

  • Cc esigra added

comment:9 Changed 11 months ago by timgraham

  • Summary changed from Using database-level CHECK CONSTRAINTS to Add the ability to use database-level CHECK CONSTRAINTS
  • Triage Stage changed from Someday/Maybe to Accepted
  • Version changed from 1.1 to master

comment:10 Changed 11 months ago by gam_phon

  • Cc gam_phon added

comment:11 Changed 8 weeks ago by rrauenza

Could/should this feature request also handle this case of constraint I brought up in this thread?

Basically unique_together doesn't consider a null value unique per SQL spec -- which makes perfect sense in single column indexes and is extended to multi column indexes.

So if someone wanted (A, B, NULL) to be a unique row there would need to be an index built on the first two columns "where <third column> is null"

These SO articles give a better overview:

comment:12 Changed 7 weeks ago by alexpirine

I would also love this feature.

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