From ffa7140c6d443c28fd2ba6b43436362ec9f6806a Mon Sep 17 00:00:00 2001 From: LtWorf Date: Fri, 18 Sep 2009 22:57:02 +0000 Subject: [PATCH] Fixed problem with float numbers with selection of certain relations git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@215 014f5005-505e-4b48-8d0a-63407b615a7c --- CHANGELOG | 3 ++- relational/relation.py | 9 +++------ relational_gui/maingui.py | 11 +++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8c433cc..7644cdc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -94,4 +94,5 @@ - Improved futile_union_intersection_subtraction in case of A-A, when A is a sub-query (Rev 208) - Improved futile_union_intersection_subtraction, handles when a branch of subtracion has a selection (Rev 209) - Can load relations specified in command line (Rev 210) -- Using fakeroot instead of su in make debian (Rev 214) \ No newline at end of file +- Using fakeroot instead of su in make debian (Rev 214) +- Fixed problem with float numbers with selection of certain relations (Rev 215) \ No newline at end of file diff --git a/relational/relation.py b/relational/relation.py index b9e5e1a..352639e 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -106,17 +106,16 @@ class relation (object): newt.header=header(list(self.header.attributes)) for i in self.content: for j in range(len(self.header.attributes)): - if i[j].isdigit(): + if len(i[j])>0 and i[j].isdigit(): attributes[self.header.attributes[j]]=int(i[j]) - elif rstring(i[j]).isFloat(): + elif len(i[j])>0 and rstring(i[j]).isFloat(): attributes[self.header.attributes[j]]=float(i[j]) - elif isDate(i[j]): + elif len(i[j])>0 and isDate(i[j]): attributes[self.header.attributes[j]]=rdate(i[j]) else: attributes[self.header.attributes[j]]=i[j] - if eval(expr,attributes): newt.content.append(i) return newt @@ -259,8 +258,6 @@ class relation (object): '''Does a left and a right outer join and returns their union.''' a=self.outer_right(other) b=self.outer_left(other) - print a - print b return a.union(b) diff --git a/relational_gui/maingui.py b/relational_gui/maingui.py index b8de897..799d581 100644 --- a/relational_gui/maingui.py +++ b/relational_gui/maingui.py @@ -159,7 +159,8 @@ class Ui_Form(object): def loadRelation(self,filename=None,name=None): '''Loads a relation. Without parameters it will ask the user which relation to load, - otherwise it will load filename, giving it name''' + otherwise it will load filename, giving it name. + It shouldn't be called giving filename but not giving name.''' #Asking for file to load if filename==None: filename = QtGui.QFileDialog.getOpenFileName(None,QtGui.QApplication.translate("Form", "Load Relation"),"",QtGui.QApplication.translate("Form", "Relations (*.csv);;Old Relations (*.tlb);;Text Files (*.txt);;All Files (*)")) @@ -183,17 +184,15 @@ class Ui_Form(object): if (defname.endswith(".csv")): #removes the extension defname=defname[:-4] - if name==None: + if name==None: #Prompt dialog to insert name for the relation res=QtGui.QInputDialog.getText(self.Form, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Insert the name for the new relation"), QtGui.QLineEdit.Normal,defname) if res[1]==False or len(res[0])==0: return - #self.relations[str(res[0].toUtf8())]=relation.relation(filename,use_csv) #Patch provided by Angelo 'Havoc' Puglisi - self.relations[str(res[0].toUtf8())]=relation.relation(str(filename.toUtf8()),use_csv) - - else: + self.relations[str(res[0].toUtf8())]=relation.relation(str(filename.toUtf8()),use_csv) + else: #name was decided by caller self.relations[name]=relation.relation(filename,use_csv) self.updateRelations()