mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Fix editing of foreign keys in Edit Table dialog
Fix a bug when removing a foreign key from a table. Fix a bug when editing an existing foreign key on a table. See issue #918.
This commit is contained in:
@@ -440,9 +440,16 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
|
||||
callRenameColumn = true;
|
||||
break;
|
||||
case kForeignKey:
|
||||
sqlb::ForeignKeyClause* fk = new sqlb::ForeignKeyClause;
|
||||
fk->setFromString(item->text(column));
|
||||
m_table.addConstraint({field}, sqlb::ConstraintPtr(fk));
|
||||
if(item->text(column).trimmed().isEmpty())
|
||||
{
|
||||
// Remove the foreign key
|
||||
m_table.removeConstraints({field}, sqlb::Constraint::ConstraintTypes::ForeignKeyConstraintType);
|
||||
} else {
|
||||
// Set the foreign key
|
||||
sqlb::ForeignKeyClause* fk = new sqlb::ForeignKeyClause;
|
||||
fk->setFromString(item->text(column));
|
||||
m_table.setConstraint({field}, sqlb::ConstraintPtr(fk));
|
||||
}
|
||||
if(!m_bNewTable)
|
||||
callRenameColumn = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user