Opened 9 years ago

Closed 9 years ago

#5152 closed (wontfix)

Model save() method needs update=False option

Reported by: sime <simon@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: model save method update insert
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I need finer grained control over the update vs insert process. It needs to skip the update check, and simply fail if it can't insert.

Change History (4)

comment:1 Changed 9 years ago by James Bennett

Triage Stage: UnreviewedDesign decision needed

I'm not sure this is a common enough need to merit handling it in Django's API; if you need to avoid UPDATE at all costs, you probably want to have code specific to your situation which checks with your database and takes whatever steps are necessary to meet your requirements for data insertion.

comment:2 Changed 9 years ago by James Bennett

Resolution: wontfix
Status: newclosed

Also, what would be the "correct" behavior for this option? Return an unsaved object? Throw an exception? Different use cases are going to want different results there, which just strengthens my suspicion that this is something application authors will need to deal with on a case-by-case basis if they need it; I'm going to mark wontfix, but if you have a strong argument for why this needs to be directly in Django itself (and how it ought to work), bring it up on the django-developers list.

comment:3 Changed 9 years ago by Densetsu no Ero-sennin <densetsu.no.ero.sennin@…>

Resolution: wontfix
Status: closedreopened

There is at least one use case for update=False in Django itself. Session framework can use it to fully avoid key collisions. See #1180.

comment:4 Changed 9 years ago by James Bennett

Resolution: wontfix
Status: reopenedclosed

I'm going to close this again because this is not the solution to any session key collision problems. Read the history of that bug if you'd like to know why.

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