Opened 17 years ago
Closed 17 years ago
#5152 closed (wontfix)
Model save() method needs update=False option
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
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: | no | UI/UX: | no |
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 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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 by , 17 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
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 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
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.
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.