[Django] #22540: .save() called in multiple "creation" queryset functions

3 views
Skip to first unread message

Django

unread,
Apr 29, 2014, 9:20:06 AM4/29/14
to django-...@googlegroups.com
#22540: .save() called in multiple "creation" queryset functions
----------------------------------------------+----------------------
Reporter: craig.labenz@… | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords: creation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------------------+----------------------
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()`.

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

Django

unread,
Apr 29, 2014, 1:57:24 PM4/29/14
to django-...@googlegroups.com
#22540: .save() called in multiple "creation" queryset functions
-------------------------------------+-------------------------------------
Reporter: craig.labenz@… | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: creation | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* easy: 1 => 0
* stage: Unreviewed => Accepted


Comment:

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

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

Django

unread,
May 2, 2014, 3:10:21 AM5/2/14
to django-...@googlegroups.com
#22540: .save() called in multiple "creation" queryset functions
-------------------------------------+-------------------------------------
Reporter: craig.labenz@… | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: creation | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0

Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/2626

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

Django

unread,
May 2, 2014, 7:17:56 AM5/2/14
to django-...@googlegroups.com
#22540: .save() called in multiple "creation" queryset functions
-------------------------------------+-------------------------------------
Reporter: craig.labenz@… | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: creation | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Accepted => Ready for checkin


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

Django

unread,
May 2, 2014, 8:00:39 AM5/2/14
to django-...@googlegroups.com
#22540: .save() called in multiple "creation" queryset functions
-------------------------------------+-------------------------------------
Reporter: craig.labenz@… | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: master
Component: Database layer | Resolution: fixed

(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: creation | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

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


Comment:

In [changeset:"0dce44e16be2d4850120cd333380ab9171c5964a"]:
{{{
#!CommitTicketReference repository=""
revision="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....@gmail.com for the report.
}}}

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

Django

unread,
May 3, 2014, 5:45:43 PM5/3/14
to django-...@googlegroups.com
#22540: .save() called in multiple "creation" queryset functions
-------------------------------------+-------------------------------------
Reporter: craig.labenz@… | Owner: nobody

Type: | Status: closed
Cleanup/optimization | Version: master
Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: creation | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"faa8c71fd9e97794e73f7e7564446846d72d8bb2"]:
{{{
#!CommitTicketReference repository=""
revision="faa8c71fd9e97794e73f7e7564446846d72d8bb2"
Moved misplaced transaction.atomic from 0dce44e16b

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

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

Reply all
Reply to author
Forward
0 new messages