-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Model.update() fails for BitFields if using flags #2257
Comments
The flags is a descriptor which, when no instance is present (e.g. accessing For now, what you want is: # clear bit
BitTest.update(flags=BitTest.flags & ~8)
# set bit
BitTest.update(flags=BitTest.flags | 8) I'm going to think about this, thanks for the report. |
Slight change in the SQL generation to exclude the boolean comparison when the flag is already part of an expression. Refs #2257
The API I have come up with is: # Set the "is_8" bit:
BitTest.update(flags=BitTest.is_8.set())
# Clear the "is_8" bit:
BitTest.update(flags=BitTest.is_8.clear()) This change is merged into master. |
The changes are great. Thank you! |
I use peewee in an application with millions of objects. I would use
Model.update()
for an effective mass updateinstead of creating objects and running
Model.bulk_update()
.Currently peewee generates wrong SQL statements for BitFields with flags:
Test with SQLite CLI
Complete example
Output example
The text was updated successfully, but these errors were encountered: