- When a query fails, shows the message of the exception

- Improved tokenizer for select in optimizations, now can accept operators in identifiers


git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@220 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
LtWorf
2010-03-19 16:06:02 +00:00
parent 6adcd221bd
commit 2c4757dafb
3 changed files with 20 additions and 33 deletions

View File

@@ -97,4 +97,6 @@
- Using fakeroot instead of su in make debian (Rev 214) - Using fakeroot instead of su in make debian (Rev 214)
- Fixed problem with float numbers with selection of certain relations (Rev 215) - Fixed problem with float numbers with selection of certain relations (Rev 215)
- Added .desktop file on svn (Rev 216) - Added .desktop file on svn (Rev 216)
- Automatically fills some fields in the survey (Rev 217) - Automatically fills some fields in the survey (Rev 217)
- When a query fails, shows the message of the exception (Rev220)
- Improved tokenizer for select in optimizations, now can accept operators in identifiers (Rev220)

View File

@@ -307,7 +307,7 @@ def tokenize_select(expression):
selection. The expression can contain parenthesis. selection. The expression can contain parenthesis.
It will use a subclass of str with the attribute level, which It will use a subclass of str with the attribute level, which
will specify the nesting level of the token into parenthesis.''' will specify the nesting level of the token into parenthesis.'''
sel_op=('//=','**=','and ','not ','in ','//','**','<<','>>','==','!=','>=','<=','+=','-=','*=','/=','%=','or ','+','-','*','/','&','|','^','~','<','>','%','=','(',')',',','[',']')
l=0 l=0
while l!=len(expression): while l!=len(expression):
l=len(expression) l=len(expression)
@@ -326,34 +326,17 @@ def tokenize_select(expression):
elif expression[0:1]==')': elif expression[0:1]==')':
level-=1 level-=1
if expression[0:3] in sel_op:#3char op for i in range(4,0,-1):#operators
t=level_string(temp) if expression[0:i] in sel_op:
t.level=level t=level_string(temp)
tokens.append(t) t.level=level
temp='' tokens.append(t)
t=level_string(expression[0:3]) temp=''
t.level=level t=level_string(expression[0:i].strip())
tokens.append(t) t.level=level
expression=expression[3:] tokens.append(t)
elif expression[0:2] in sel_op:#2char op expression=expression[i:]
t=level_string(temp) if expression[0:1]=="'":#String
t.level=level
tokens.append(t)
temp=''
t=level_string(expression[0:2])
t.level=level
tokens.append(t)
expression=expression[2:]
elif expression[0:1] in sel_op:#1char op
t=level_string(temp)
t.level=level
tokens.append(t)
temp=''
t=level_string(expression[0:1])
t.level=level
tokens.append(t)
expression=expression[1:]
elif expression[0:1]=="'":#String
end=expression.index("'",1) end=expression.index("'",1)
while expression[end-1]=='\\': while expression[end-1]=='\\':
end=expression.index("'",end+1) end=expression.index("'",end+1)
@@ -560,4 +543,6 @@ def selection_and_product(n,rels):
general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection,subsequent_renames,swap_rename_select,futile_union_intersection_subtraction,swap_union_renames,swap_rename_projection] general_optimizations=[duplicated_select,down_to_unions_subtractions_intersections,duplicated_projection,selection_inside_projection,subsequent_renames,swap_rename_select,futile_union_intersection_subtraction,swap_union_renames,swap_rename_projection]
specific_optimizations=[selection_and_product] specific_optimizations=[selection_and_product]
if __name__=="__main__":
print tokenize_select("skill == 'C' and id % 2 == 0")

View File

@@ -84,8 +84,8 @@ class Ui_Form(object):
self.updateRelations() #update the list self.updateRelations() #update the list
self.selectedRelation=result self.selectedRelation=result
self.showRelation(self.selectedRelation) #Show the result in the table self.showRelation(self.selectedRelation) #Show the result in the table
except: except Exception, e:
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Check your query!") ) QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.message) )
def showRelation(self,rel): def showRelation(self,rel):
'''Shows the selected relation into the table''' '''Shows the selected relation into the table'''
self.table.clear() self.table.clear()