EditTableDialog: Fix adding new fields to table

Fix the function to add new columns to an existing table to work
properly with the recent changes.
This commit is contained in:
Martin Kleusberg
2013-05-31 14:21:11 +02:00
parent b1333c90c7
commit 7e319bd80f

View File

@@ -117,16 +117,6 @@ void EditTableDialog::accept()
} else {
// Editing of old table
// add added fields
// TODO this will not work if an added field is marked
// as autoincrement
QString sTablesql = pdb->getTableSQL(curTable);
sqlb::Table oldschema = sqlb::Table::parseSQL(sTablesql);
for( int i = oldschema.fields().count(); i < m_table.fields().count(); ++i)
{
pdb->addColumn(curTable, m_table.fields().at(i));
}
// Rename table if necessary
if(ui->editTableName->text() != curTable)
{
@@ -326,6 +316,10 @@ void EditTableDialog::addField()
));
m_table.addField(f);
// Actually add the new column to the table if we're editing an existing table
if(!m_bNewTable)
pdb->addColumn(curTable, f);
checkInput();
}