Move code to rename table to DBBrowserDB class

Move the code to rename a table from the EditTableForm to the
DBBrowserDB class where it should be and where it obviously was intended
to be.
This commit is contained in:
Martin Kleusberg
2013-01-07 22:43:31 +01:00
parent 7904b594ed
commit b0af89c1cb
2 changed files with 15 additions and 9 deletions

View File

@@ -428,9 +428,18 @@ bool DBBrowserDB::renameColumn(QString tablename, QString from, QString to, QStr
return true;
}
bool DBBrowserDB::renameTable(QString from_table, QString to_table){
qDebug("renameTable");
return true;
bool DBBrowserDB::renameTable(QString from_table, QString to_table)
{
QString sql = QString("ALTER TABLE `%1` RENAME TO `%2`").arg(from_table, to_table);
if(!executeSQL(sql))
{
QString error = QString("Error renaming table '%1' to '%2'. Message from database engine:\n%3").arg(from_table).arg(to_table).arg(lastErrorMessage);
lastErrorMessage = error;
qDebug(error.toStdString().c_str());
return false;
} else {
return true;
}
}
void DBBrowserDB::getTableRecords( const QString & tablename, const QString& orderby )