diff --git a/CHANGELOG b/CHANGELOG index 0a5bab6..17f37ce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -68,4 +68,4 @@ 0.10 - In optimizer, added a function that tokenizes an expression - Document about complexity of operations -- Bug: error in rename operator, it didn't perform a fullcopy of the relation \ No newline at end of file +- Bug: error in update operation, it changed the original tuple, so also other relations using the same tuple would change. Now it copies it. \ No newline at end of file diff --git a/complexity b/complexity index ad01302..a7224a1 100644 --- a/complexity +++ b/complexity @@ -122,5 +122,5 @@ Notation 2.9 Join - Same as above. + Same as above. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/relational/relation.py b/relational/relation.py index 98d4bb0..f208179 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -446,8 +446,14 @@ class relation (object): attributes[self.header.attributes[j]]=i[j] if eval(expr,attributes): #If expr is true, changing the tuple affected+=1 + new_tuple=list(i) + #Deleting the tuple, instead of changing it, so other + #relations can still point to the same list without + #being affected. + self.content.remove(i) for k in range(len(keys)): - i[f_ids[k]]=str(dic[keys[k]]) + new_tuple[f_ids[k]]=str(dic[keys[k]]) + self.content.append(new_tuple) return affected def insert(self,values): '''Inserts a tuple in the relation.