Skip to content

Commit 5e5817c

Browse files
committed
5.0: Update django.db.models.constraints.UniqueConstraint
Reflects the nulls_distinct option of the UniqueConstraint class. Adds the attribute and the arg to the two versions of the __init__ type definitions. https://docs.djangoproject.com/en/5.0/ref/models/constraints/#nulls-distinct
1 parent e5bda21 commit 5e5817c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

django-stubs/db/models/constraints.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class UniqueConstraint(BaseConstraint):
5353
fields: Sequence[str]
5454
condition: Q | None
5555
deferrable: Deferrable | None
56+
nulls_distinct: bool | None
5657

5758
@overload
5859
def __init__(
@@ -64,6 +65,7 @@ class UniqueConstraint(BaseConstraint):
6465
deferrable: Deferrable | None = ...,
6566
include: Sequence[str] | None = ...,
6667
opclasses: Sequence[Any] = ...,
68+
nulls_distinct: bool | None = ...,
6769
violation_error_code: str | None = ...,
6870
violation_error_message: _StrOrPromise | None = ...,
6971
) -> None: ...

tests/typecheck/db/models/test_constraints.yml

+10
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,13 @@
3535
main:4: note: Possible overload variants:
3636
main:4: note: .*
3737
main:4: note: .*
38+
39+
- case: unique_constraint_nulls_distinct
40+
main: |
41+
from django.db.models import Q, UniqueConstraint
42+
43+
UniqueConstraint(
44+
fields=['name'],
45+
name='unqiue_name',
46+
nulls_distinct=True,
47+
)

0 commit comments

Comments
 (0)