GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • src
    • EditTableDialog.cpp
    • sqlitedb.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/EditTableDialog.cpp‎

Copy file name to clipboardExpand all lines: src/EditTableDialog.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
232232
// we need to check for this case and cancel here. Maybe we can think of some way to modify the INSERT INTO ... SELECT statement
233233
// to at least replace all troublesome NULL values by the default value
234234
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()));
236236
if(m.data(m.index(0, 0)).toInt() > 0)
237237
{
238238
// There is a NULL value, so print an error message, uncheck the combobox, and return here
Collapse file

‎src/sqlitedb.cpp‎

Copy file name to clipboardExpand all lines: src/sqlitedb.cpp
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
436436

437437
bool DBBrowserDB::getRow(const QString& sTableName, int rowid, QList<QByteArray>& rowdata)
438438
{
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);
440440
QByteArray utf8Query = sQuery.toUtf8();
441441
sqlite3_stmt *stmt;
442442
bool ret = false;
@@ -488,7 +488,7 @@ bool DBBrowserDB::deleteRecord(const QString& table, int rowid)
488488
bool ok = false;
489489
lastErrorMessage = QString("no error");
490490

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);
492492

493493
if (_db){
494494
logSQL(statement, kLogMsg_App);
@@ -510,7 +510,7 @@ bool DBBrowserDB::updateRecord(const QString& table, const QString& column, int
510510

511511
lastErrorMessage = QString("no error");
512512

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);
514514

515515
logSQL(sql, kLogMsg_App);
516516
setRestorePoint();

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.