Esempio n. 1
0
    def agregarNuevoTipo(self, tablaAMod, colAMod, nuevoTipo):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaAMod)

        tipoFinal = {
            '_tipoColumna': str(nuevoTipo._tipoColumna),
            '_paramOne': nuevoTipo._paramOne,
            '_paramTwo': nuevoTipo._paramTwo
        }

        for columna in tableToAlter.columns:
            if (columna._name == colAMod):
                bandera = True
                columna._dataType = tipoFinal
                break

        if not bandera:
            desc = f": Undefined column in alter type ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        typeChecker.writeFile()
        pass
Esempio n. 2
0
    def agregarCheck(self, conditionColumn, tablaId):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaId)

        #                           L (L|D)*
        whatColumnIs = re.search('[a-zA-z]([a-zA-z]|[0-9])*',
                                 conditionColumn.alias)

        if whatColumnIs != None:
            whatColumnIs = whatColumnIs.group(0)
            for columna in tableToAlter.columns:
                if (columna._name == whatColumnIs):
                    bandera = True
                    columna._check = conditionColumn.alias
                    break
            if not bandera:
                desc = f": Undefined column in alter check ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                return
            bandera = False

        else:
            desc = f": column not given in check()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        typeChecker.writeFile()
Esempio n. 3
0
    def agregarFk(self, listaCols, nombreTabla, listaTablasCols, tablaAAlter):

        typeChecker = TypeChecker()

        # the len of the cols must be de same
        if len(listaCols) != len(listaTablasCols):
            desc = f": cantidad of params in foreign() != "
            ErrorController().add(36, 'Execution', desc, 0, 0)
            return

        existForeingTable = typeChecker.searchTable(SymbolTable().useDatabase,
                                                    nombreTabla)
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaAAlter)

        # validate if the foreign table exists
        if existForeingTable == None:
            desc = f": Undefined table in foreign key ()"
            ErrorController().add(27, 'Execution', desc, 0, 0)
            return

        # validate if the columns exists in the foreign table
        for coli in listaTablasCols:
            if typeChecker.searchColumn(existForeingTable, coli) == None:
                desc = f": Undefined col in table in foreign key ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                return

        bandera = False
        for x in range(0, len(listaCols)):
            for columna in tableToAlter.columns:
                if (columna._name == listaCols[x]):
                    bandera = True
                    columna._foreignKey = {
                        '_refTable': nombreTabla,
                        '_refColumn': listaTablasCols[x]
                    }
                    break
            if not bandera:
                desc = f": Undefined column in alter foreign key ()"
                ErrorController().add(26, 'Execution', desc, 0, 0)
                return
            bandera = False

        typeChecker.writeFile()
Esempio n. 4
0
    def agregarNotNull(self, tablaAMod, colAMod):
        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               tablaAMod)

        for columna in tableToAlter.columns:
            if (columna._name == colAMod):
                bandera = True
                columna._notNull = True
                break

        if not bandera:
            desc = f": Undefined column in alter not null ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        typeChecker.writeFile()
Esempio n. 5
0
    def process(self, instrucction):

        typeChecker = TypeChecker()
        bandera = False
        tableToAlter = typeChecker.searchTable(SymbolTable().useDatabase,
                                               instrucction)

        for columna in tableToAlter.columns:
            if (columna._name == self._oldName):
                bandera = True
                columna._name = self._newName
                break

        if not bandera:
            desc = f": Undefined column in rename column ()"
            ErrorController().add(26, 'Execution', desc, 0, 0)
            return
        bandera = False
        typeChecker.writeFile()