示例#1
0
 def changeCol(self, strTableName, old, new):
     self.changeColType(strTableName, attribsToDict(old), attribsToDict(new))
     
     self.changeAutoIncrement(strTableName, old, new)
     
     self.changeColDefaults(strTableName, old, new)
     
     self.changeColComments(strTableName, old, new)
示例#2
0
    def changeCol(self, strTableName, old, new):
        self.changeColType(strTableName, attribsToDict(old),
                           attribsToDict(new))

        self.changeAutoIncrement(strTableName, old, new)

        self.changeColDefaults(strTableName, old, new)

        self.changeColComments(strTableName, old, new)
示例#3
0
    def createView(self, ignore, new, nIndex):
        attribs = attribsToDict(new)
        strDefinition = new.firstChild.nodeValue.rstrip()

        if self.inDbms(new):
            self.ddli.addView(new.getAttribute('name'), strDefinition, attribs,
                              self.diffs)
示例#4
0
 def changeColDefaults(self, strTableName, old, new):
     strOldDefault = old.getAttribute('default')
     strNewDefault = new.getAttribute('default')
     if strNewDefault != strOldDefault:
         self.ddli.changeColDefault(
             strTableName, getColName(new), strNewDefault,
             self.ddli.retColTypeEtc(attribsToDict(new)), self.diffs)
示例#5
0
    def renameFunction(self, ignore, old, new):
        attribs = attribsToDict(new)
        strDefinition = new.firstChild.nodeValue.strip()

        if self.inDbms(new):
            self.ddli.renameFunction(old.getAttribute('name'),
                                     new.getAttribute('name'), strDefinition,
                                     attribs, self.diffs)
示例#6
0
 def changeColComments(self, strTableName, old, new):
     # Check for difference in comments.
     strNewComment = safeGet(new, 'desc')
     strOldComment = safeGet(old, 'desc')
     if strNewComment and strNewComment != strOldComment:
         # Fix to delete comments?
         self.ddli.changeColumnComment(
             strTableName, getColName(new), strNewComment,
             self.ddli.retColTypeEtc(attribsToDict(new)), self.diffs)
示例#7
0
 def createFunction(self, ignore, new, nIndex):
     attribs = attribsToDict(new)
     strDefinition = new.firstChild.nodeValue.strip()
     
     # strNewFunctionName, argumentList, strReturn, strContents, attribs, diffs
     argumentList = [arg.strip() for arg in new.getAttribute('arguments').split(',')]
     
     if self.inDbms(new):
         self.ddli.addFunction(new.getAttribute('name'), argumentList, new.getAttribute('returns'), strDefinition.strip(), attribs, self.diffs)
示例#8
0
 def changeAutoIncrement(self, strTableName, old, new):
     # Remove old, and new
     strOldAuto = old.getAttribute('autoincrement').lower()
     strNewAuto = new.getAttribute('autoincrement').lower()
     if strOldAuto != strNewAuto:
         if strNewAuto == 'yes':
             # Hmm, if we created the column the autoincrement would already be there anyway.
             pass
             #print "Add Autoincrement TODO"
         else:
             self.ddli.dropAutoIncrement(strTableName, attribsToDict(old), self.diffs)
示例#9
0
 def diffView(self, ignore, oldView, newView):
     strOldContents = oldView.firstChild.nodeValue.rstrip()
     strNewContents = newView.firstChild.nodeValue.rstrip()
     
     if not self.inDbms(newView):
         return
         
     if strOldContents != strNewContents:
         attribs = attribsToDict(newView)
         strDefinition = newView.firstChild.nodeValue.rstrip()
         
         self.ddli.updateView(newView.getAttribute('name'), strDefinition, attribs, self.diffs)
示例#10
0
 def changeAutoIncrement(self, strTableName, old, new):
     # Remove old, and new
     strOldAuto = old.getAttribute('autoincrement').lower()
     strNewAuto = new.getAttribute('autoincrement').lower()
     if strOldAuto != strNewAuto:
         if strNewAuto == 'yes':
             # Hmm, if we created the column the autoincrement would already be there anyway.
             pass
             #print "Add Autoincrement TODO"
         else:
             self.ddli.dropAutoIncrement(strTableName, attribsToDict(old),
                                         self.diffs)
示例#11
0
 def renameColumn(self, strTableName, old, new):
     strOldName = getColName(old)
     strNewName = getColName(new)
     
     if self.params['drop_constraints_on_col_rename']:
         self.dropRelatedConstraints(strTableName, strOldName)
         
     columnType = self.ddli.retColTypeEtc(attribsToDict(new))
     self.ddli.renameColumn(strTableName, strOldName, strNewName, columnType, self.diffs)
     
     if self.params['drop_constraints_on_col_rename']:
         self.rebuildRelatedConstraints(strTableName, strNewName)
示例#12
0
    def diffView(self, ignore, oldView, newView):
        strOldContents = oldView.firstChild.nodeValue.rstrip()
        strNewContents = newView.firstChild.nodeValue.rstrip()

        if not self.inDbms(newView):
            return

        if strOldContents != strNewContents:
            attribs = attribsToDict(newView)
            strDefinition = newView.firstChild.nodeValue.rstrip()

            self.ddli.updateView(newView.getAttribute('name'), strDefinition,
                                 attribs, self.diffs)
示例#13
0
 def diffFunction(self, ignore, oldFunction, newFunction):
     strOldContents = oldFunction.firstChild.nodeValue.strip()
     strNewContents = newFunction.firstChild.nodeValue.strip()
     
     if not self.inDbms(newFunction):
         return
     
     if strOldContents != strNewContents:
         attribs = attribsToDict(newFunction)
         strDefinition = newFunction.firstChild.nodeValue.strip()
         
         self.ddli.updateFunction(newFunction.getAttribute('name'), 
             newFunction.getAttribute('arguments').split(','), newFunction.getAttribute('returns'), strDefinition, attribs, self.diffs)
示例#14
0
    def createFunction(self, ignore, new, nIndex):
        attribs = attribsToDict(new)
        strDefinition = new.firstChild.nodeValue.strip()

        # strNewFunctionName, argumentList, strReturn, strContents, attribs, diffs
        argumentList = [
            arg.strip() for arg in new.getAttribute('arguments').split(',')
        ]

        if self.inDbms(new):
            self.ddli.addFunction(new.getAttribute('name'), argumentList,
                                  new.getAttribute('returns'),
                                  strDefinition.strip(), attribs, self.diffs)
示例#15
0
    def renameColumn(self, strTableName, old, new):
        strOldName = getColName(old)
        strNewName = getColName(new)

        if self.params['drop_constraints_on_col_rename']:
            self.dropRelatedConstraints(strTableName, strOldName)

        columnType = self.ddli.retColTypeEtc(attribsToDict(new))
        self.ddli.renameColumn(strTableName, strOldName, strNewName,
                               columnType, self.diffs)

        if self.params['drop_constraints_on_col_rename']:
            self.rebuildRelatedConstraints(strTableName, strNewName)
示例#16
0
    def retColumnDefinition(self, col, strPreDdl, strPostDdl):
        strColName = getColName(col)

        strRet = self.ddlInterface.quoteName(
            strColName) + ' ' + self.ddlInterface.retColTypeEtc(
                attribsToDict(col))

        if col.hasAttribute('autoincrement') and col.getAttribute(
                'autoincrement').lower() == "yes":
            strTableName = getTableName(col.parentNode.parentNode)
            strRet += self.ddlInterface.addAutoIncrement(
                strTableName, strColName, col.getAttribute('default'),
                strPreDdl, strPostDdl)

        return strRet
示例#17
0
    def diffFunction(self, ignore, oldFunction, newFunction):
        strOldContents = oldFunction.firstChild.nodeValue.strip()
        strNewContents = newFunction.firstChild.nodeValue.strip()

        if not self.inDbms(newFunction):
            return

        if strOldContents != strNewContents:
            attribs = attribsToDict(newFunction)
            strDefinition = newFunction.firstChild.nodeValue.strip()

            self.ddli.updateFunction(
                newFunction.getAttribute('name'),
                newFunction.getAttribute('arguments').split(','),
                newFunction.getAttribute('returns'), strDefinition, attribs,
                self.diffs)
示例#18
0
    def retColumnDefinition(self, col, strPreDdl, strPostDdl):
        strColName = getColName(col)
        
        strRet = self.ddlInterface.quoteName(strColName) + ' ' + self.ddlInterface.retColTypeEtc(attribsToDict(col))
        
        if col.hasAttribute('autoincrement') and col.getAttribute('autoincrement').lower() == "yes":
            strTableName = getTableName(col.parentNode.parentNode)
            strRet += self.ddlInterface.addAutoIncrement(strTableName, strColName, col.getAttribute('default'), strPreDdl, strPostDdl)

        return strRet
示例#19
0
 def changeColComments(self, strTableName, old, new):
     # Check for difference in comments.
     strNewComment = safeGet(new, 'desc')
     strOldComment = safeGet(old, 'desc')
     if strNewComment and strNewComment != strOldComment:
         # Fix to delete comments?
         self.ddli.changeColumnComment(strTableName, getColName(new), strNewComment, self.ddli.retColTypeEtc(attribsToDict(new)), self.diffs)
示例#20
0
 def _dropRelatedSequence(self, strTableName, col):
     if col.getAttribute('autoincrement').lower() == 'yes':
         self.ddli.dropAutoIncrement(strTableName, attribsToDict(col), self.diffs)
示例#21
0
 def addColumn(self, strTableName, new, nAfter):
     """ nAfter not used yet """
     
     self.ddli.addColumn(strTableName, getColName(new), self.ddli.retColTypeEtc(attribsToDict(new)), nAfter, self.diffs)
示例#22
0
 def createView(self, ignore, new, nIndex):
     attribs = attribsToDict(new)
     strDefinition = new.firstChild.nodeValue.rstrip()
     
     if self.inDbms(new):
         self.ddli.addView(new.getAttribute('name'), strDefinition, attribs, self.diffs)
示例#23
0
 def renameFunction(self, ignore, old, new):
     attribs = attribsToDict(new)
     strDefinition = new.firstChild.nodeValue.strip()
     
     if self.inDbms(new):
         self.ddli.renameFunction(old.getAttribute('name'), new.getAttribute('name'), strDefinition, attribs, self.diffs)
示例#24
0
 def changeColDefaults(self, strTableName, old, new):
     strOldDefault = old.getAttribute('default')
     strNewDefault = new.getAttribute('default')
     if strNewDefault != strOldDefault:
         self.ddli.changeColDefault(strTableName, getColName(new), strNewDefault, self.ddli.retColTypeEtc(attribsToDict(new)), self.diffs)
示例#25
0
    def addColumn(self, strTableName, new, nAfter):
        """ nAfter not used yet """

        self.ddli.addColumn(strTableName, getColName(new),
                            self.ddli.retColTypeEtc(attribsToDict(new)),
                            nAfter, self.diffs)
示例#26
0
 def _dropRelatedSequence(self, strTableName, col):
     if col.getAttribute('autoincrement').lower() == 'yes':
         self.ddli.dropAutoIncrement(strTableName, attribsToDict(col),
                                     self.diffs)