Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#35554 closed Bug (fixed)

Model.save() positional argument parsing slightly incorrect

Reported by: Adam Johnson Owned by: Adam Johnson
Component: Database layer (models, ORM) Version: 5.1
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (6)

comment:1 by Jacob Walls, 4 months ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 by Natalia Bidart, 4 months ago

Needs tests: set
Patch needs improvement: set

comment:3 by Jacob Walls, 4 months ago

Has patch: set

comment:4 by Natalia Bidart, 4 months ago

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:5 by GitHub <noreply@…>, 4 months ago

Resolution: fixed
Status: assignedclosed

In 28522c3:

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+nessita@…>

comment:6 by Natalia <124304+nessita@…>, 4 months ago

In 38717291:

[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+nessita@…>

Backport of 28522c3c8d5eb581347aececc3ac61c134528114 from main.

Note: See TracTickets for help on using tickets.
Back to Top