diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 92e5d6c88..9dfd81caa 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -775,11 +775,13 @@ void MainWindow::closeEvent( QCloseEvent* event ) void MainWindow::addRecord() { int row = m_browseTableModel->rowCount(); - if(m_browseTableModel->insertRow(row)) + bool isWithoutRowidTable = db.getObjectByName(currentlyBrowsedTableName())->type() == sqlb::Object::Table && db.getObjectByName(currentlyBrowsedTableName())->isWithoutRowidTable(); + + if(!isWithoutRowidTable && m_browseTableModel->insertRow(row)) { selectTableLine(row); } else { - // Error inserting empty row. + // Table without rowid (let user enter value for PK) or error inserting empty row. // User has to provide values acomplishing the constraints. Open Add Record Dialog. insertValues(); } diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index 103aa0dbf..ddaee0310 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -393,6 +393,12 @@ bool SqliteTableModel::setTypedData(const QModelIndex& index, bool isBlob, const { cached_row.replace(index.column(), newValue); lock.unlock(); + // Special case for rowid columns + if(m_headers.at(index.column()) == m_sRowidColumn) { + cached_row.replace(0, newValue); + const QModelIndex& rowidIndex = index.sibling(index.row(), 0); + emit dataChanged(rowidIndex, rowidIndex); + } emit dataChanged(index, index); return true; } else {