Simplified delete method

This commit is contained in:
Salvo 'LtWorf' Tomaselli 2015-06-01 08:45:29 +02:00
parent be6400c270
commit 766a3a6527

View File

@ -495,19 +495,13 @@ class relation (object):
This operation will change the relation itself instead of generating a new one, This operation will change the relation itself instead of generating a new one,
deleting all the tuples that make expr true. deleting all the tuples that make expr true.
Returns the number of affected rows.''' Returns the number of affected rows.'''
self._make_writable()
attributes = {}
affected = len(self.content)
new_content = set() # New content of the relation
for i in self.content:
for j in range(len(self.header.attributes)):
attributes[self.header.attributes[j]] = self._autocast(i[j])
if not eval(expr, attributes): #Not necessary self._make_writable()
affected -= 1
new_content.add(i) l = len(self.content)
self.content = new_content self._readonly = False
return affected self.content = self.difference(self.selection(expr)).content
return len(self.content) - l
class header (object): class header (object):