I think there should be a option like `case_insensitive=True` that can be
passed to `UniqueConstraint` so the `UniqueConstraint` create a functional
unique index with `Lower`.
I know, its possible to store the value as lower case always and mitigate
this issue, but it does not provide DB level constrains safety from
anomaly.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> case insensitive unique constraint is needed for various purposes like
> storing emails. In postgresql, its possible to add
> [https://www.postgresql.org/message-
> id/c57a8ecec259afdc...@mitre.org, a functional unique index
> with `Lower`] and it will work as a case insensitive unique constraint. I
> have tried to implement that functional unique index/constraint in
> django, but looking at the source it seems that it is not possible to add
> functional unique index/constraint in django.
> [https://github.com/django/django/pull/11929, PR 11929] is created for
> adding functional index, but it seems like it is not possible to create
> unique functional index with it.
>
> I think there should be a option like `case_insensitive=True` that can be
> passed to `UniqueConstraint` so the `UniqueConstraint` create a
> functional unique index with `Lower`.
>
> I know, its possible to store the value as lower case always and mitigate
> this issue, but it does not provide DB level constrains safety from
> anomaly.
New description:
Case insensitive unique constraint is needed for various purposes like
storing emails. In postgresql, its possible to add
[https://www.postgresql.org/message-
id/c57a8ecec259afdc...@mitre.org, a functional unique index
with `Lower`] and it will work as a case insensitive unique constraint. I
have tried to implement that functional unique index/constraint in django,
but looking at the source it seems that it is not possible to add
functional unique index/constraint in django.
[https://github.com/django/django/pull/11929, PR 11929] is created for
adding functional index, but it seems like it is not possible to create
unique functional index with it.
I think there should be a option like `case_insensitive=True` that can be
passed to `UniqueConstraint` so the `UniqueConstraint` create a functional
unique index with `Lower`.
I know, its possible to store the value as lower case always and mitigate
this issue, but it does not provide DB level constrains safety from
anomaly.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:1>
Old description:
> Case insensitive unique constraint is needed for various purposes like
> storing emails. In postgresql, its possible to add
> [https://www.postgresql.org/message-
> id/c57a8ecec259afdc...@mitre.org, a functional unique index
> with `Lower`] and it will work as a case insensitive unique constraint. I
> have tried to implement that functional unique index/constraint in
> django, but looking at the source it seems that it is not possible to add
> functional unique index/constraint in django.
> [https://github.com/django/django/pull/11929, PR 11929] is created for
> adding functional index, but it seems like it is not possible to create
> unique functional index with it.
>
> I think there should be a option like `case_insensitive=True` that can be
> passed to `UniqueConstraint` so the `UniqueConstraint` create a
> functional unique index with `Lower`.
>
> I know, its possible to store the value as lower case always and mitigate
> this issue, but it does not provide DB level constrains safety from
> anomaly.
New description:
Case insensitive unique constraint is needed for various purposes like
storing emails. In postgresql, its possible to add
[https://www.postgresql.org/message-
id/c57a8ecec259afdc...@mitre.org a functional unique index
with `Lower`] and it will work as a case insensitive unique constraint. I
have tried to implement that functional unique index/constraint in django,
but looking at the source it seems that it is not possible to add
functional unique index/constraint in django.
[https://github.com/django/django/pull/11929 PR 11929] is created for
adding functional index, but it seems like it is not possible to create
unique functional index with it.
I think there should be a option like `case_insensitive=True` that can be
passed to `UniqueConstraint` so the `UniqueConstraint` create a functional
unique index with `Lower`.
I know, its possible to store the value as lower case always and mitigate
this issue, but it does not provide DB level constrains safety from
anomaly.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:2>
* keywords: UniqueConstraint => constraint functional
* stage: Unreviewed => Accepted
Comment:
Should we close this one as a duplicate of #26167.
I'll at least rename the issue to more generic name.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:3>
* owner: nobody => saadalsaad
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:4>
* version: 2.2 => master
Comment:
Probably some or most of logic can be reused from functional indexes
(#26167) (e.g. with a mixin) but I think we should treat this as a
separate feature.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:5>
* has_patch: 0 => 1
Comment:
Looking the history in github it seems that was closed because the code
was merged, but after that it had improvement/modifications, it would be
interesting if the author can clarify the status of the PR, if the
discussion is about the same thing or about other things.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:6>
* has_patch: 1 => 0
Comment:
CarlosMirdeSouza, this patch doesn't have a patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:7>
Comment (by CarlosMirdeSouza):
He references the PR 11929, it doesn't count has a patch?
https://github.com/django/django/pull/11929
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:8>
Comment (by CarlosMirdeSouza):
I was confused, my bad, sorryfor the mistake, it references the PR for
other ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:9>
Comment (by felixxm):
[https://github.com/django/django/pull/11929 PR11929] is about functional
indexes, not functional constraints.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:10>
Comment (by CarlosMirdeSouza):
Thanks for the explanation, i will have more attention for next time.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:11>
Comment (by saadalsaad):
from my understanding, we need to support for functional constraints by
adding case_insensitive option to UniqueConstraint ?
https://github.com/django/django/pull/12115
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:12>
Comment (by felixxm):
saadalsaad, no. This ticket is about adding support for functional
constraints not only about case insensitive check constraints. It's more
generic.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:13>
Comment (by saadalsaad):
felixxm, since this ticket is generic for functional constraints, can we
move case_insensitive option to a sperate ticket?
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:14>
Comment (by felixxm):
saadalsaad, not really we don't want to add such specific parameters.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:15>
Comment (by saadalsaad):
Replying to [ticket:30916 Safwan Rahman]:
> Case insensitive unique constraint is needed for various purposes like
storing emails. In postgresql, its possible to add
[https://www.postgresql.org/message-
id/c57a8ecec259afdc...@mitre.org a functional unique index
with `Lower`] and it will work as a case insensitive unique constraint. I
have tried to implement that functional unique index/constraint in django,
but looking at the source it seems that it is not possible to add
functional unique index/constraint in django.
[https://github.com/django/django/pull/11929 PR 11929] is created for
adding functional index, but it seems like it is not possible to create
unique functional index with it.
>
> I think there should be a option like `case_insensitive=True` that can
be passed to `UniqueConstraint` so the `UniqueConstraint` create a
functional unique index with `Lower`.
>
> I know, its possible to store the value as lower case always and
mitigate this issue, but it does not provide DB level constrains safety
from anomaly.
Ticket description suggested adding case_insensitive option to be added in
UniqueConstraint to create a functional unique index with `Lower`
since we are not going to add such option, seems we need to modify ticket
description
felixxm, do you mean supporting functional constraints (supporting
expressions in class based constraints ?) similar to indexes in #26167 ?
Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:16>
Comment (by felixxm):
Replying to [comment:16 saadalsaad]:
> felixxm, do you mean supporting functional constraints (supporting
expressions in class based constraints ?) similar to indexes in #26167 ?
>
> Thanks
Yes exactly, see [https://code.djangoproject.com/ticket/30916?#comment:5
comment].
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:17>
Comment (by Sanskar Jaiswal):
Was a common consensus reached regarding this? I would love to give this a
shot if I could understand what all we expect from this feature.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:18>
* cc: Ian Foote (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:19>
* cc: Hannes Ljungberg (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:20>
* owner: saadalsaad => Hannes Ljungberg
Comment:
I intend to create a patch for this after
[https://code.djangoproject.com/ticket/26167 #26167] is merged.
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:21>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/13983
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:22>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:23>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:24>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:25>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3aa545281e0c0f9fac93753e3769df9e0334dbaa" 3aa5452]:
{{{
#!CommitTicketReference repository=""
revision="3aa545281e0c0f9fac93753e3769df9e0334dbaa"
Fixed #30916 -- Added support for functional unique constraints.
Thanks Ian Foote and Mariusz Felisiak for reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30916#comment:26>