coleifer / peewee

a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb
http://docs.peewee-orm.com/
MIT License
11.06k stars 1.37k forks source link

the count is diffrent #2903

Closed thadqy closed 3 months ago

thadqy commented 3 months ago

count = User.update(**update_dict).where((User.deleted == 0) & (User.id == user.id)).execute()

and

updateQuery= User.update(**update_dict).where((User.deleted == 0) & (User.id == user.id)) count = updateQuery.execute()

the count is diffrent

coleifer commented 3 months ago

This is incorrect.

coleifer commented 3 months ago

Just to prove it to you,

from peewee import *

#db = SqliteDatabase(':memory:')
db = PostgresqlDatabase('peewee_test')

class User(db.Model):
    name = TextField()
    deleted = IntegerField()
    status = IntegerField()

db.drop_tables([User])
db.create_tables([User])

User.create(name='u0', deleted=0, status=0)

count = User.update(status=1).where(
    (User.deleted == 0) &
    (User.name == 'u0')).execute()

q = User.update(status=1).where(
    (User.deleted == 0) &
    (User.name == 'u0'))
count2 = q.execute()

print(count, count2)
db.drop_tables([User])

Output is 1 1

coleifer commented 3 months ago

Please take more time when opening issues.