- Forces relations to have correct attribute names
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@296 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
dfb3f19acf
commit
3ca26b10c6
@ -1,5 +1,6 @@
|
|||||||
1.1
|
1.1
|
||||||
- Incorrect relational operations now raise an exception instead of returning None
|
- Incorrect relational operations now raise an exception instead of returning None
|
||||||
|
- Forces relations to have correct names for attributes
|
||||||
|
|
||||||
1.0
|
1.0
|
||||||
- Adds history in the GUI
|
- Adds history in the GUI
|
||||||
|
@ -512,6 +512,10 @@ class header (object):
|
|||||||
'''Accepts a list with attributes' names. Names MUST be unique'''
|
'''Accepts a list with attributes' names. Names MUST be unique'''
|
||||||
self.attributes=attributes
|
self.attributes=attributes
|
||||||
|
|
||||||
|
for i in attributes:
|
||||||
|
if not is_valid_relation_name(i):
|
||||||
|
raise Exception('"%s" is not a valid attribute name'% i)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "header(%s)" % (self.attributes.__repr__())
|
return "header(%s)" % (self.attributes.__repr__())
|
||||||
|
|
||||||
@ -519,6 +523,10 @@ class header (object):
|
|||||||
def rename(self,old,new):
|
def rename(self,old,new):
|
||||||
'''Renames a field. Doesn't check if it is a duplicate.
|
'''Renames a field. Doesn't check if it is a duplicate.
|
||||||
Returns True if the field was renamed, False otherwise'''
|
Returns True if the field was renamed, False otherwise'''
|
||||||
|
|
||||||
|
if not is_valid_relation_name(new):
|
||||||
|
raise Exception('%s is not a valid attribute name'% new)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
id_=self.attributes.index(old)
|
id_=self.attributes.index(old)
|
||||||
self.attributes[id_]=new
|
self.attributes[id_]=new
|
||||||
|
@ -190,11 +190,19 @@ class relForm(QtGui.QMainWindow):
|
|||||||
#Patch provided by Angelo 'Havoc' Puglisi
|
#Patch provided by Angelo 'Havoc' Puglisi
|
||||||
name=str(res[0].toUtf8())
|
name=str(res[0].toUtf8())
|
||||||
|
|
||||||
if rtypes.is_valid_relation_name(name):
|
if not rtypes.is_valid_relation_name(name):
|
||||||
self.relations[name]=relation.relation(filename)
|
|
||||||
self.updateRelations()
|
|
||||||
else:
|
|
||||||
QtGui.QMessageBox.information(self,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Wrong name for destination relation: %s." % name))
|
QtGui.QMessageBox.information(self,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Wrong name for destination relation: %s." % name))
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.relations[name]=relation.relation(filename)
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.__str__()) )
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
self.updateRelations()
|
||||||
|
|
||||||
def insertTuple(self):
|
def insertTuple(self):
|
||||||
'''Shows an input dialog and inserts the inserted tuple into the selected relation'''
|
'''Shows an input dialog and inserts the inserted tuple into the selected relation'''
|
||||||
|
@ -24,6 +24,7 @@ import logging
|
|||||||
import os.path
|
import os.path
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import curses
|
||||||
|
|
||||||
from relational import relation, parser, rtypes
|
from relational import relation, parser, rtypes
|
||||||
|
|
||||||
@ -261,6 +262,17 @@ def exec_query(command):
|
|||||||
print e
|
print e
|
||||||
|
|
||||||
def main(files=[]):
|
def main(files=[]):
|
||||||
|
|
||||||
|
import locale
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
code = locale.getpreferredencoding()
|
||||||
|
|
||||||
|
print curses.can_change_color()
|
||||||
|
|
||||||
|
curses.color_pair(curses.A_BOLD)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "> ; Type HELP to get the HELP"
|
print "> ; Type HELP to get the HELP"
|
||||||
print "> ; Completion is activated using the tab (if supported by the terminal)"
|
print "> ; Completion is activated using the tab (if supported by the terminal)"
|
||||||
|
|
||||||
@ -285,4 +297,5 @@ def main(files=[]):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
main()
|
main()
|
Loading…
Reference in New Issue
Block a user