Initial support for multiple primary key columns in WITHOUT ROWID tables

This add initial and mostly untested support for WITHOUT ROWID tables
with multiple primary key columns. It should now be possible to update
and to delete records in these tables.

This commit also improves the overall handling of multiple primary key
columns in preparation for better support of them in general.

Note that this makes us depend on an SQLite version with a built-in JSON
extension.

See issues #516, #1075, and #1834.
This commit is contained in:
Martin Kleusberg
2019-04-01 21:28:34 +02:00
parent b788e2ddc8
commit a615c7b5a0
11 changed files with 146 additions and 90 deletions

View File

@@ -967,7 +967,7 @@ void MainWindow::addRecord()
void MainWindow::insertValues()
{
QString pseudo_pk = m_browseTableModel->hasPseudoPk() ? m_browseTableModel->pseudoPk() : QString();
QString pseudo_pk = m_browseTableModel->hasPseudoPk() ? QString::fromStdString(m_browseTableModel->pseudoPk().front()) : QString();
AddRecordDialog dialog(db, currentlyBrowsedTableName(), this, pseudo_pk);
if (dialog.exec())
populateTable();
@@ -3314,7 +3314,7 @@ void MainWindow::jumpToRow(const sqlb::ObjectIdentifier& table, QString column,
// If no column name is set, assume the primary key is meant
if(!column.size())
column = obj->findPk()->name();
column = obj->primaryKey().first();
// If column doesn't exist don't do anything
auto column_index = sqlb::findField(obj, column);
@@ -3564,7 +3564,7 @@ void MainWindow::unlockViewEditing(bool unlock, QString pk)
// (De)activate editing
enableEditing(unlock);
m_browseTableModel->setPseudoPk(pk);
m_browseTableModel->setPseudoPk({pk.toStdString()});
// Update checked status of the popup menu action
ui->actionUnlockViewEditing->blockSignals(true);