GeezerVison is showing github.com — Improve support for 'WITHOUT rowid' tables · feiva/sqlitebrowser@e37df86
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/EditTableDialog.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -232,7 +232,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column) |
232 | 232 | // we need to check for this case and cancel here. Maybe we can think of some way to modify the INSERT INTO ... SELECT statement |
233 | 233 | // to at least replace all troublesome NULL values by the default value |
234 | 234 | SqliteTableModel m(this, pdb); |
235 | | - m.setQuery(QString("SELECT COUNT(_rowid_) FROM `%1` WHERE `%2` IS NULL;").arg(curTable).arg(field->name())); |
| 235 | + m.setQuery(QString("SELECT COUNT(`%1`) FROM `%2` WHERE `%3` IS NULL;").arg(pdb->getObjectByName(curTable).table.rowidColumn()).arg(curTable).arg(field->name())); |
236 | 236 | if(m.data(m.index(0, 0)).toInt() > 0) |
237 | 237 | { |
238 | 238 | // There is a NULL value, so print an error message, uncheck the combobox, and return here |
|
Collapse file
Copy file name to clipboardExpand all lines: src/sqlitedb.cpp +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -436,7 +436,7 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log |
436 | 436 |
|
437 | 437 | bool DBBrowserDB::getRow(const QString& sTableName, int rowid, QList<QByteArray>& rowdata) |
438 | 438 | { |
439 | | - QString sQuery = QString("SELECT * from %1 WHERE _rowid_=%2;").arg(sTableName).arg(rowid); |
| 439 | + QString sQuery = QString("SELECT * from %1 WHERE `%2`=%3;").arg(sTableName).arg(getObjectByName(sTableName).table.rowidColumn()).arg(rowid); |
440 | 440 | QByteArray utf8Query = sQuery.toUtf8(); |
441 | 441 | sqlite3_stmt *stmt; |
442 | 442 | bool ret = false; |
@@ -488,7 +488,7 @@ bool DBBrowserDB::deleteRecord(const QString& table, int rowid) |
488 | 488 | bool ok = false; |
489 | 489 | lastErrorMessage = QString("no error"); |
490 | 490 |
|
491 | | - QString statement = QString("DELETE FROM `%1` WHERE _rowid_=%2;").arg(table).arg(rowid); |
| 491 | + QString statement = QString("DELETE FROM `%1` WHERE `%2`=%3;").arg(table).arg(getObjectByName(table).table.rowidColumn()).arg(rowid); |
492 | 492 |
|
493 | 493 | if (_db){ |
494 | 494 | logSQL(statement, kLogMsg_App); |
@@ -510,7 +510,7 @@ bool DBBrowserDB::updateRecord(const QString& table, const QString& column, int |
510 | 510 |
|
511 | 511 | lastErrorMessage = QString("no error"); |
512 | 512 |
|
513 | | - QString sql = QString("UPDATE `%1` SET `%2`=? WHERE _rowid_=%3;").arg(table).arg(column).arg(row); |
| 513 | + QString sql = QString("UPDATE `%1` SET `%2`=? WHERE `%3`=%4;").arg(table).arg(column).arg(getObjectByName(table).table.rowidColumn()).arg(row); |
514 | 514 |
|
515 | 515 | logSQL(sql, kLogMsg_App); |
516 | 516 | setRestorePoint(); |
|