New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for select clause in bulk_update #2265
Comments
Since you are already explicitly specifying the |
It's not – think of my use case as "defensive" bulk updating of an attribute, for example allow only changes to I think this can be done in Django as follows, but I'm not entirely sure (haven't tried): Foo.objects.filter(x=0).bulk_update(foos, ['x']) As an alternative, what do you think about factoring out the |
I'm not clear why you would be using bulk_update in that case? Presumably a regular-old update() query would work better? |
Because the |
A relational database provides atomicity and isolation, so presumably there's a different way to handle that. I think this is a rather obscure usage because it implies that you are updating values from a list of models, but also that some of those models may be "out-of-sync". This, to me, is not an API failure but rather a result of trying to shoehorn some logic into a process that would be better handled another way. |
Isn't the scenario simply a case of a more general version of optimistic locking as described in the docs? http://docs.peewee-orm.com/en/latest/peewee/hacks.html#optimistic-locking There we have a version column, and no bulk update; here we have a non-version column with bulk update. |
Add support for optional select clause in
bulk_update
, for example to allow for something likeI quickly hacked this together like this, and it seems to work.
The text was updated successfully, but these errors were encountered: