mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Problems with WITHOUT ROWID tables
Quoted values in DELETE FROM and UPDATE SET take into account that value could have a single quote and they are now doubled. Detect tables without rowid in order to make invisible the "Show rowid column" See issue #1332
This commit is contained in:
@@ -595,8 +595,9 @@ void MainWindow::populateTable()
|
||||
if(db.getObjectByName(currentlyBrowsedTableName())->type() == sqlb::Object::Table)
|
||||
{
|
||||
// Table
|
||||
sqlb::TablePtr table = db.getObjectByName(currentlyBrowsedTableName()).dynamicCast<sqlb::Table>();
|
||||
ui->actionUnlockViewEditing->setVisible(false);
|
||||
ui->actionShowRowidColumn->setVisible(true);
|
||||
ui->actionShowRowidColumn->setVisible(!table->isWithoutRowidTable());
|
||||
} else {
|
||||
// View
|
||||
ui->actionUnlockViewEditing->setVisible(true);
|
||||
|
||||
@@ -980,8 +980,8 @@ bool DBBrowserDB::deleteRecords(const sqlb::ObjectIdentifier& table, const QStri
|
||||
if (!isOpen()) return false;
|
||||
|
||||
QStringList quoted_rowids;
|
||||
for(const QString& rowid : rowids)
|
||||
quoted_rowids.append("'" + rowid + "'");
|
||||
for(QString rowid : rowids)
|
||||
quoted_rowids.append("'" + rowid.replace("'", "''") + "'");
|
||||
|
||||
QString statement = QString("DELETE FROM %1 WHERE %2 IN (%3);")
|
||||
.arg(table.toString())
|
||||
@@ -1022,7 +1022,7 @@ bool DBBrowserDB::updateRecord(const sqlb::ObjectIdentifier& table, const QStrin
|
||||
.arg(table.toString())
|
||||
.arg(sqlb::escapeIdentifier(column))
|
||||
.arg(pk)
|
||||
.arg(rowid);
|
||||
.arg(QString(rowid).replace("'", "''"));
|
||||
|
||||
logSQL(sql, kLogMsg_App);
|
||||
setSavepoint();
|
||||
|
||||
Reference in New Issue
Block a user