From 39a27aef710bbd9fa13be11b02ec960daea17075 Mon Sep 17 00:00:00 2001 From: LtWorf Date: Fri, 3 Apr 2009 19:03:02 +0000 Subject: [PATCH] Bug: error in update operation, it changed the original tuple, so also other relations using the same tuple would change. Now it copies it git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@122 014f5005-505e-4b48-8d0a-63407b615a7c --- CHANGELOG | 2 +- complexity | 2 +- relational/relation.py | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) 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.