keredson / peewee

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

calling .update on an object will update every record in the database of that type #10

Open smtheard opened 7 years ago

smtheard commented 7 years ago

eg.

>>> page = Page.get(id=1)
>>> page.update(name="this is probably not how this should work").execute()
('UPDATE pages SET "name" = %s', [u'this is probably not how this should work'])
1110
>>> Page.ALL.count()
('SELECT Count(*) FROM pages AS p1', [])
1110L
keredson commented 7 years ago

I think you're calling the class method there, not the instance method.

smtheard commented 7 years ago

@keredson I think that's what happening too but it was pretty unexpected, seems like an instance method should be there (or maybe throw an exception so it doesn't call the model function?)

keredson commented 7 years ago

Yeah I agree with that.

On Nov 18, 2016 6:40 PM, "Stefan Theard" notifications@github.com wrote:

@keredson https://github.com/keredson I think that's what happening too but it was pretty unexpected, seems like an instance method should be there (or maybe throw an exception so it doesn't call the model function?)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/keredson/peewee/issues/10#issuecomment-261678218, or mute the thread https://github.com/notifications/unsubscribe-auth/AB9GgSvXy7nLcEQEqWJ-4DlDLYQdB5rPks5q_kVfgaJpZM4K278a .