Check for pseudo-PKs when determining whether the model is editable

This commit is contained in:
Martin Kleusberg
2018-01-13 16:29:17 +01:00
parent 512b694114
commit 58ab9cc1b7
2 changed files with 3 additions and 1 deletions

View File

@@ -948,6 +948,8 @@ QString DBBrowserDB::addRecord(const sqlb::ObjectIdentifier& tablename)
if (!isOpen()) return QString();
sqlb::TablePtr table = getObjectByName(tablename).dynamicCast<sqlb::Table>();
if(!table)
return QString();
// For tables without rowid we have to set the primary key by ourselves. We do so by querying for the largest value in the PK column
// and adding one to it.

View File

@@ -938,7 +938,7 @@ void SqliteTableModel::setPseudoPk(const QString& pseudoPk)
bool SqliteTableModel::isEditable() const
{
return !m_sTable.isEmpty() && m_db.getObjectByName(m_sTable)->type() == sqlb::Object::Types::Table;
return !m_sTable.isEmpty() && (m_db.getObjectByName(m_sTable)->type() == sqlb::Object::Types::Table || !m_pseudoPk.isEmpty());
}
void SqliteTableModel::waitForFetchingFinished()