dbbrowserdb: Correctly identify NULL values when returning row

Commit 9e4a6df changed the way fetchData() handles NULL values
so they could be seen by the user. However, the same change wasn't
added to DBBrowserDB::getRow().

Because both are called by the table model and we now add colors
to NULL fields, this caused a visible bug when adding a row with
not null column constraints.

See issue #214.
This commit is contained in:
Samir Aguiar
2015-03-05 22:45:50 +01:00
parent f1ac26e216
commit befb60376c

View File

@@ -586,7 +586,18 @@ bool DBBrowserDB::getRow(const QString& sTableName, int64_t rowid, QList<QByteAr
while(sqlite3_step(stmt) == SQLITE_ROW)
{
for (int i = 0; i < sqlite3_column_count(stmt); ++i)
rowdata.append(QByteArray(static_cast<const char*>(sqlite3_column_blob(stmt, i)), sqlite3_column_bytes(stmt, i)));
{
if(sqlite3_column_type(stmt, i) == SQLITE_NULL)
{
rowdata.append(QByteArray());
} else {
int bytes = sqlite3_column_bytes(stmt, i);
if(bytes)
rowdata.append(QByteArray(static_cast<const char*>(sqlite3_column_blob(stmt, i)), bytes));
else
rowdata.append(QByteArray(""));
}
}
ret = true;
}
}