[Django] #34135: Add async interface to ManyRelatedManager & RelatedManager

82 views
Skip to first unread message

Django

unread,
Nov 2, 2022, 5:22:14 PM11/2/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon | Owner: nobody
Janzen |
Type: | Status: new
Uncategorized |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords: async
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
With #34112 and #33646 combined, there is now an async interface for
reading/writing Models in a lot of cases. One of the obvious places where
that isn't true is in `RelatedManager` instances. `RelatedManager`
instances are missing async versions of:

* `add`
* `remove`
* `clear`
* `set`

And this might be a separate ticket but the docs [1] are missing a
reference to `acreate` which according to `dir()` exists on
`ManyRelatedManager` (I assume as a consequence of inheriting from some
superclass `Manager` type) but I didn't actually try and see if it works.
I'm suspicious that it might not be fully correct as
`related_descriptors.py` includes a possibly custom version of the
synchronous `create` function (see [2] & [3]).

[1]
https://docs.djangoproject.com/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager
[2]
https://github.com/django/django/blob/main/django/db/models/fields/related_descriptors.py#L788-L792
[3]
https://github.com/django/django/blob/main/django/db/models/fields/related_descriptors.py#L1186-L1190

--
Ticket URL: <https://code.djangoproject.com/ticket/34135>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 2, 2022, 5:24:54 PM11/2/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jon Janzen):

FWIW I'm also willing to work on a PR for this ticket, assuming a similar
solution to #34112.

(apologies if this ticket is not well-formed or I missed another ticket
that covers the same topics)

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:1>

Django

unread,
Nov 2, 2022, 5:27:16 PM11/2/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Jon Janzen:

Old description:

> With #34112 and #33646 combined, there is now an async interface for
> reading/writing Models in a lot of cases. One of the obvious places where
> that isn't true is in `RelatedManager` instances. `RelatedManager`
> instances are missing async versions of:
>
> * `add`
> * `remove`
> * `clear`
> * `set`
>
> And this might be a separate ticket but the docs [1] are missing a
> reference to `acreate` which according to `dir()` exists on
> `ManyRelatedManager` (I assume as a consequence of inheriting from some
> superclass `Manager` type) but I didn't actually try and see if it works.
> I'm suspicious that it might not be fully correct as
> `related_descriptors.py` includes a possibly custom version of the
> synchronous `create` function (see [2] & [3]).
>
> [1]
> https://docs.djangoproject.com/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager
> [2]
> https://github.com/django/django/blob/main/django/db/models/fields/related_descriptors.py#L788-L792
> [3]
> https://github.com/django/django/blob/main/django/db/models/fields/related_descriptors.py#L1186-L1190

New description:

With #34112 and #33646 combined, there is now an async interface for
reading/writing Models in a lot of cases. One of the obvious places where
that isn't true is in `RelatedManager` instances. `RelatedManager`
instances are missing async versions of:

* `add`
* `remove`
* `clear`
* `set`

And this might be a separate ticket but the docs (1) are missing a


reference to `acreate` which according to `dir()` exists on
`ManyRelatedManager` (I assume as a consequence of inheriting from some
superclass `Manager` type) but I didn't actually try and see if it works.
I'm suspicious that it might not be fully correct as
`related_descriptors.py` includes a possibly custom version of the

synchronous `create` function (see (2) & (3)).

(1)
https://docs.djangoproject.com/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager
(2)
https://github.com/django/django/blob/main/django/db/models/fields/related_descriptors.py#L788-L792
(3)
https://github.com/django/django/blob/main/django/db/models/fields/related_descriptors.py#L1186-L1190

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:2>

Django

unread,
Nov 3, 2022, 2:09:57 AM11/3/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: nobody
Type: New feature | Status: new

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Carlton Gibson (added)
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


Comment:

Sounds reasonable.

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:3>

Django

unread,
Nov 3, 2022, 2:55:55 AM11/3/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jon Janzen):

* owner: nobody => Jon Janzen
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:4>

Django

unread,
Nov 3, 2022, 2:50:21 PM11/3/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Jon Janzen:

Old description:

> With #34112 and #33646 combined, there is now an async interface for
> reading/writing Models in a lot of cases. One of the obvious places where
> that isn't true is in `RelatedManager` instances. `RelatedManager`
> instances are missing async versions of:
>
> * `add`
> * `remove`
> * `clear`
> * `set`
>

New description:

(1)
https://docs.djangoproject.com/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:5>

Django

unread,
Nov 3, 2022, 4:21:35 PM11/3/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jon Janzen):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/16252 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:6>

Django

unread,
Nov 7, 2022, 2:16:05 AM11/7/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:7>

Django

unread,
Nov 7, 2022, 3:53:18 AM11/7/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Bhuvnesh):

I would like to submit an improvement patch if not jon.

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:8>

Django

unread,
Nov 7, 2022, 4:01:02 AM11/7/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:8 Bhuvnesh]:


> I would like to submit an improvement patch if not jon.

There is no need for a new patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:9>

Django

unread,
Nov 9, 2022, 4:13:52 AM11/9/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: async | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:10>

Django

unread,
Nov 9, 2022, 5:09:43 AM11/9/22
to django-...@googlegroups.com
#34135: Add async interface to ManyRelatedManager & RelatedManager
-------------------------------------+-------------------------------------
Reporter: Jon Janzen | Owner: Jon
| Janzen
Type: New feature | Status: closed

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: async | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"321ecb40f4da842926e1bc07e11df4aabe53ca4b" 321ecb40]:
{{{
#!CommitTicketReference repository=""
revision="321ecb40f4da842926e1bc07e11df4aabe53ca4b"
Fixed #34135 -- Added async-compatible interface to related managers.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34135#comment:11>

Reply all
Reply to author
Forward
0 new messages