﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30053	Allow for conditional QuerySet.update_or_create()	Joshua Cannon	Nasir Hussain	"{{{QuerySet.update_or_create()}}} is great since it lifts the burden of thread-safety and repeated code from the client. However there exists some scenarios where the ""update"" logic should be hidden behind a condition. (E.g. only update if the value of a {{{DateTimeField}}} is less than some value). There isn't much help for clients in these scenarios, with the best solution being to copy+paste {{{QuerySet.update_or_create()}}} and wrap the {{{setattr}}}-and-{{{save}}} logic in a conditional (worst case being they roll their own code, which likely would lead to thread-safety issues)

The condition would most likely be a callable that accepts one argument, the {{{got}}}ten instance.

The solution should be trivial, either:
A. Add a ""condition"" parameter to {{{update_or_create()}}} (along with logic to make the feature backwards compatible, likely checking if the value is callable with one argument or not, since ""condition"" could be a field)
B. Add another method, and re-write {{{update_or_create()}}} in terms of the new method with a condition that is always true.
"	New feature	closed	Database layer (models, ORM)	dev	Normal	wontfix	QuerySet update_or_create	Nasir Hussain Adam Johnson	Unreviewed	1	0	0	0	0	0
