From 8ceb72d8195dcaf7175350c331f7cfefdb6ad66a Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 2 Feb 2017 21:36:42 +0100 Subject: [PATCH] Support filtering for NULL values See issue #588. --- src/sqlitetablemodel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index 3e3ada902..128f8f808 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -622,8 +622,19 @@ void SqliteTableModel::updateFilter(int column, const QString& value) numeric = true; } } else if(value.left(1) == "=") { - op = "="; val = value.mid(1); + + // Check if value to compare with is 'NULL' + if(val != "NULL") + { + // It's not, so just compare normally to the value, whatever it is. + op = "="; + } else { + // It is NULL. Override the comparison operator to search for NULL values in this column. Also treat search value (NULL) as number, + // in order to avoid putting quotes around it. + op = "IS"; + numeric = true; + } } else { // Keep the default LIKE operator