[Django] #35554: Model.save() positional argument parsing slightly incorrect

8 views
Skip to first unread message

Django

unread,
Jun 24, 2024, 8:38:28 AM (5 days ago) Jun 24
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: Bug | Status: assigned
Component: Database | Version: 5.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Ticket #35060 introduced a deprecation pathway for positional arguments in
`Model.save()`. The code introduced to match positional arguments is
slightly incorrect, leading to some subtle behaviour changes:

1. Calling with extra positional arguments, such as `Model.save(False,
False, None, None, None)`, no longer raises a `TypeError`.
2. Calling with positional empty `update_fields`, such as
`Model.save(False, False, None, [])`, would try to save all fields, due to
truthy-checking of arguments.

These are definitely edge cases, but we can easily avoid them with
alternative parsing logic. PR incoming.
--
Ticket URL: <https://code.djangoproject.com/ticket/35554>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 24, 2024, 9:19:45 AM (5 days ago) Jun 24
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted

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

Django

unread,
Jun 24, 2024, 3:16:28 PM (5 days ago) Jun 24
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

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

Django

unread,
Jun 25, 2024, 7:57:37 AM (4 days ago) Jun 25
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* has_patch: 0 => 1

Comment:

[https://github.com/django/django/pull/18304 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/35554#comment:3>

Django

unread,
Jun 25, 2024, 8:33:39 AM (4 days ago) Jun 25
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | 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 Natalia Bidart):

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

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

Django

unread,
Jun 25, 2024, 12:12:21 PM (4 days ago) Jun 25
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | 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 GitHub <noreply@…>):

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

Comment:

In [changeset:"28522c3c8d5eb581347aececc3ac61c134528114" 28522c3]:
{{{#!CommitTicketReference repository=""
revision="28522c3c8d5eb581347aececc3ac61c134528114"
Fixed #35554, Refs #35060 -- Corrected deprecated *args parsing in
Model.save()/asave().

The transitional logic added to deprecate the usage of *args for
Model.save()/asave() introduced two issues that this branch fixes:
* Passing extra positional arguments no longer raised TypeError.
* Passing a positional but empty update_fields would save all fields.

Co-authored-by: Natalia <124304+...@users.noreply.github.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35554#comment:5>

Django

unread,
Jun 25, 2024, 12:14:48 PM (4 days ago) Jun 25
to django-...@googlegroups.com
#35554: Model.save() positional argument parsing slightly incorrect
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"387172918f65762578d93a9b3f94d20209f7a769" 38717291]:
{{{#!CommitTicketReference repository=""
revision="387172918f65762578d93a9b3f94d20209f7a769"
[5.1.x] Fixed #35554, Refs #35060 -- Corrected deprecated *args parsing in
Model.save()/asave().

The transitional logic added to deprecate the usage of *args for
Model.save()/asave() introduced two issues that this branch fixes:
* Passing extra positional arguments no longer raised TypeError.
* Passing a positional but empty update_fields would save all fields.

Co-authored-by: Natalia <124304+...@users.noreply.github.com>

Backport of 28522c3c8d5eb581347aececc3ac61c134528114 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35554#comment:6>
Reply all
Reply to author
Forward
0 new messages