Improve support for 'WITHOUT rowid' tables

This adds support for editing and deleting rows from tables without
rowid. It also fixes a check in the EditTableDialog when activating the
not null constraint as well as making some progress when it comes to
adding new rows.

Also see issue #51.
This commit is contained in:
Martin Kleusberg
2014-08-26 17:58:33 +02:00
parent 7d4248ecb4
commit e37df8658c
2 changed files with 4 additions and 4 deletions

View File

@@ -232,7 +232,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
// we need to check for this case and cancel here. Maybe we can think of some way to modify the INSERT INTO ... SELECT statement
// to at least replace all troublesome NULL values by the default value
SqliteTableModel m(this, pdb);
m.setQuery(QString("SELECT COUNT(_rowid_) FROM `%1` WHERE `%2` IS NULL;").arg(curTable).arg(field->name()));
m.setQuery(QString("SELECT COUNT(`%1`) FROM `%2` WHERE `%3` IS NULL;").arg(pdb->getObjectByName(curTable).table.rowidColumn()).arg(curTable).arg(field->name()));
if(m.data(m.index(0, 0)).toInt() > 0)
{
// There is a NULL value, so print an error message, uncheck the combobox, and return here