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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
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)
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
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)
def _dropRelatedSequence(self, strTableName, col): if col.getAttribute('autoincrement').lower() == 'yes': self.ddli.dropAutoIncrement(strTableName, attribsToDict(col), self.diffs)
def addColumn(self, strTableName, new, nAfter): """ nAfter not used yet """ self.ddli.addColumn(strTableName, getColName(new), self.ddli.retColTypeEtc(attribsToDict(new)), nAfter, self.diffs)
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)