Permalink
Browse files

bugfix for delete method

  • Loading branch information...
lzyy committed Apr 25, 2012
1 parent 02d5933 commit ca4d50e5c660df29574a0cc05093a83dfed63672
Showing with 3 additions and 3 deletions.
  1. +3 −3 thing/thing.py
View
@@ -115,7 +115,7 @@ def _init_env(self):
@property
def saved(self):
return not bool(self._unsaved_items)
-
+
def __delattr__(self, key):
if key in self._current_item:
del self._current_item[key]
@@ -297,8 +297,8 @@ def delete(self):
self._before_delete()
if self._primary_key in self._current_item.keys():
pk = self._primary_key
- query = self.table.delete().where(getattr(self.table.c, pk), self._current_item[pk])
- rowcount = db.execute().rowcount
+ query = self.table.delete().where(getattr(self.table.c, pk) == self._current_item[pk])
+ rowcount = db.execute(query).rowcount
else:
query = self.table.delete(and_(*self._filters))
rowcount = db.execute(query).rowcount

0 comments on commit ca4d50e

Please sign in to comment.