Open kizjig opened 4 years ago
I don't think we have any way to do this. Since you can't do a conditional update from a .Update()
on an already-selected model.
Another ask on a similar topic is to be able to control the set
part of update clause.
So we could do things like
update ... set counter = counter + 1 ...
update ... set props = props || '{"json": "rules"}'
Set value based on computation involving an existing value (column or anything else in db)
I think this is a basic feature... How can we gracefully translate "UPDATE ... SET ... = ... WHERE ..." into sqlboiler?
I'm using SqlBoiler in my project and it's been going well - so thanks for making it 👍
I'm wonder if SqlBoiler supports updating a single table model object with a where clause. Specifically we'd like to have some logic to avoid stale updates of a single object in the style of...
psudeo sql code:-
update … where <update_column> = same_value_we_have
update … where updated_at = myobj.updated_at
So I'd imagine the SqlBoiler logic wrapper syntax might look something like...
rowsAff, err := myModel.Update(db, boil.Infer()).Where("updated_at = ?", myModel.UpdatedAt)
Is there any support for something like this that still makes use of the object wrappers and is better than just writing raw sql update statements?