Improve error handling when moving table to a different schema

When moving an existing table to a different schema which already
contains a table of that name, this causes an error. With this commit we
try to detect this type of error as early as possible.

This commit also updates the error message for that case. The old error
message still mentioned the 'temporary flag' which isn't correct
anymore.

Also, when changing the schema fails, reset the dropdown box back to a
working schema to avoid any confusion about whether the change worked or
not.
This commit is contained in:
Martin Kleusberg
2017-09-04 20:21:56 +02:00
parent 72d64edbe0
commit f01ad409ff
2 changed files with 15 additions and 6 deletions

View File

@@ -733,8 +733,8 @@ void EditTableDialog::changeSchema(const QString& schema)
{
if(!pdb.renameColumn(curTable, m_table, QString(), sqlb::FieldPtr(), 0, schema))
{
QMessageBox::warning(this, QApplication::applicationName(),
tr("Setting the temporary flag for the table failed. Error message:\n%1").arg(pdb.lastError()));
QMessageBox::warning(this, QApplication::applicationName(), tr("Changing the table schema failed. Error message:\n%1").arg(pdb.lastError()));
ui->comboSchema->setCurrentText(curTable.schema()); // Set it back to the original schema
}
}
}