Skip to content

Commit

Permalink
Rename table another way ??
Browse files Browse the repository at this point in the history
a bit wtf with the temp table ???
  • Loading branch information
pedromorgan committed Oct 5, 2010
1 parent 949f5b9 commit 7432e10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 14 additions & 6 deletions sqlitebrowser/sqlitebrowser/edittableform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ void editTableForm::renameTable()
//qDebug(newName);
//QString sql;
//do the sql rename here
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))) goto rollback;
//if (!pdb->executeSQL(QString("BEGIN TRANSACTION;"))){
// goto rollback;
//}
QString sql = QString("ALTER TABLE %1 RENAME TO %2").arg(curTable, newName);
qDebug(sql);
if (!pdb->executeSQL(sql)){
qDebug("OOPS");
qDebug( pdb->lastErrorMessage);
}else{
qDebug("OK");
}
return;
}
// sql = "CREATE TEMPORARY TABLE TEMP_TABLE(";
Expand Down Expand Up @@ -176,11 +184,11 @@ void editTableForm::renameTable()
// QApplication::restoreOverrideCursor(); // restore original cursor
// return;
//
// rollback:
// QApplication::restoreOverrideCursor(); // restore original cursor
// QString error = "Error renaming table. Message from database engine: ";
// error.append(pdb->lastErrorMessage);
// QMessageBox::warning( this, applicationName, error );
rollback:
QApplication::restoreOverrideCursor(); // restore original cursor
QString error = "Error renaming table. Message from database engine: ";
error.append(pdb->lastErrorMessage);
QMessageBox::warning( this, applicationName, error );
// pdb->executeSQL(QString("DROP TABLE TEMP_TABLE;"));
// //pdb->executeSQL(QString("ROLLBACK;"));
// setActiveTable(pdb, curTable);
Expand Down
3 changes: 2 additions & 1 deletion sqlitebrowser/sqlitebrowser/renametableform.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class Ui_renameTableForm

void setupUi(QDialog *renameTableForm)
{
if (renameTableForm->objectName().isEmpty())
if (renameTableForm->objectName().isEmpty()){
renameTableForm->setObjectName(QString::fromUtf8("renameTableForm"));
}
renameTableForm->resize(313, 101);
vboxLayout = new QVBoxLayout(renameTableForm);
vboxLayout->setSpacing(6);
Expand Down

0 comments on commit 7432e10

Please sign in to comment.