Skip to content

Commit bec2725

Browse files
committed
Add QuerySet.(a)update_or_create new create_defaults arg
1 parent 7564f79 commit bec2725

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

django-stubs/db/models/manager.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ class BaseManager(Generic[_T]):
6969
async def aget_or_create(
7070
self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any
7171
) -> tuple[_T, bool]: ...
72-
def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ...
72+
def update_or_create(
73+
self,
74+
defaults: MutableMapping[str, Any] | None = ...,
75+
create_defaults: MutableMapping[str, Any] | None = ...,
76+
**kwargs: Any,
77+
) -> tuple[_T, bool]: ...
7378
async def aupdate_or_create(
74-
self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any
79+
self,
80+
defaults: MutableMapping[str, Any] | None = ...,
81+
create_defaults: MutableMapping[str, Any] | None = ...,
82+
**kwargs: Any,
7583
) -> tuple[_T, bool]: ...
7684
def earliest(self, *fields: str | OrderBy) -> _T: ...
7785
async def aearliest(self, *fields: str | OrderBy) -> _T: ...

django-stubs/db/models/query.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,17 @@ class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized):
9898
async def aget_or_create(
9999
self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any
100100
) -> tuple[_T, bool]: ...
101-
def update_or_create(self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any) -> tuple[_T, bool]: ...
101+
def update_or_create(
102+
self,
103+
defaults: MutableMapping[str, Any] | None = ...,
104+
create_defaults: MutableMapping[str, Any] | None = ...,
105+
**kwargs: Any,
106+
) -> tuple[_T, bool]: ...
102107
async def aupdate_or_create(
103-
self, defaults: MutableMapping[str, Any] | None = ..., **kwargs: Any
108+
self,
109+
defaults: MutableMapping[str, Any] | None = ...,
110+
create_defaults: MutableMapping[str, Any] | None = ...,
111+
**kwargs: Any,
104112
) -> tuple[_T, bool]: ...
105113
def earliest(self, *fields: str | OrderBy) -> _Row: ...
106114
async def aearliest(self, *fields: str | OrderBy) -> _Row: ...

scripts/stubtest/allowlist_todo_django50.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ django.contrib.gis.db.models.Func.allowed_default
7373
django.contrib.gis.db.models.Lookup.allowed_default
7474
django.contrib.gis.db.models.Prefetch.get_current_querysets
7575
django.contrib.gis.db.models.Q.identity
76-
django.contrib.gis.db.models.QuerySet.aupdate_or_create
77-
django.contrib.gis.db.models.QuerySet.update_or_create
7876
django.contrib.gis.db.models.Value.allowed_default
7977
django.contrib.gis.db.models.When.allowed_default
8078
django.contrib.gis.db.models.functions.ClosestPoint
@@ -183,8 +181,6 @@ django.db.models.Func.allowed_default
183181
django.db.models.Lookup.allowed_default
184182
django.db.models.Prefetch.get_current_querysets
185183
django.db.models.Q.identity
186-
django.db.models.QuerySet.aupdate_or_create
187-
django.db.models.QuerySet.update_or_create
188184
django.db.models.Value.allowed_default
189185
django.db.models.When.allowed_default
190186
django.db.models.constraints.BaseConstraint.__init__
@@ -225,8 +221,6 @@ django.db.models.lookups.IntegerLessThan.overflow_exception
225221
django.db.models.lookups.IntegerLessThanOrEqual
226222
django.db.models.lookups.Lookup.allowed_default
227223
django.db.models.query.Prefetch.get_current_querysets
228-
django.db.models.query.QuerySet.aupdate_or_create
229-
django.db.models.query.QuerySet.update_or_create
230224
django.db.models.query_utils.FilteredRelation.relabeled_clone
231225
django.db.models.query_utils.FilteredRelation.resolve_expression
232226
django.db.models.query_utils.Q.identity

0 commit comments

Comments
 (0)