Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22540 closed Cleanup/optimization (fixed)

.save() called in multiple "creation" queryset functions

Reported by: craig.labenz@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: creation
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

Both create() and _create_object_from_params() (which is obviously called by get_or_create()), have raw calls to save(). It would be nice if one of those two low level creation functions used the other so additional logic pinned to create() by custom managers would also be available to get_or_create().

Change History (5)

comment:1 by Tim Graham, 11 years ago

Easy pickings: unset
Triage Stage: UnreviewedAccepted

Looking at the code briefly I think it might be possible.

comment:3 by Tim Graham, 11 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 0dce44e16be2d4850120cd333380ab9171c5964a:

Fixed #22540 -- Made _create_object_from_params() call create()

So as the save step is centralized in create(), especially useful
when customizing behavior in subclasses.
Thanks craig.labenz@… for the report.

comment:5 by Claude Paroz <claude@…>, 11 years ago

In faa8c71fd9e97794e73f7e7564446846d72d8bb2:

Moved misplaced transaction.atomic from 0dce44e16b

Thanks Florian Apolloner for noticing the issue and Aymeric
Augustin for the expertise.
Refs #22540.

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