#36592: Incorrect warning when specifying a UniqueConstraint with SQLite and nulls_distinct=False -------------------------------------+------------------------------------- Reporter: Russell Owen | Owner: (none) Type: Bug | Status: closed Component: Database layer | Version: 5.2 (models, ORM) | Severity: Normal | Resolution: invalid Keywords: SQLite | Triage Stage: UniqueConstraint | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Tim Graham):
* resolution: => invalid * status: new => closed Comment: A problem with your proposal is that the behavior of whether or not nulls are distinct is database dependent. In fact, the behavior of SQLite is the opposite of what you stated: null values are considered distinct. The docs for [https://docs.djangoproject.com/en/dev/ref/models/constraints/#django.db.models.UniqueConstraint.nulls_distinct UniqueConstraint.nulls_distinct] says: "The default value is None which uses the database default which is True on most backends." I don't think there's a strong argument to make this check aware of the default treatment of nulls. Using a different database in testing and production is highly advised against. Indeed, your `UniqueConstraint` example highlights a feature of PostgreSQL that SQLite doesn't support. -- Ticket URL: <https://code.djangoproject.com/ticket/36592#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/01070199123136e5-8be6b3a6-e802-45ba-a03a-521abf3cb54b-000000%40eu-central-1.amazonses.com.