Skip to content

Commit 2845cab

Browse files
committed
Add '<>NULL' filter
Extend the filter syntax to allow filtering for fields that are not equal to NULL. See issue #1124.
1 parent 8021523 commit 2845cab

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎src/sqlitetablemodel.cpp‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,23 @@ void SqliteTableModel::updateFilter(int column, const QString& value)
711711
val2.clear();
712712
if(value.left(2) == ">=" || value.left(2) == "<=" || value.left(2) == "<>")
713713
{
714-
bool ok;
715-
value.mid(2).toFloat(&ok);
716-
if(ok)
714+
// Check if we're filtering for '<> NULL'. In this case we need a special comparison operator.
715+
if(value.left(2) == "<>" && value.mid(2) == "NULL")
717716
{
718-
op = value.left(2);
719-
val = value.mid(2);
717+
// We are filtering for '<> NULL'. Override the comparison operator to search for NULL values in this column. Also treat search value (NULL) as number,
718+
// in order to avoid putting quotes around it.
719+
op = "IS NOT";
720720
numeric = true;
721+
val = "NULL";
722+
} else {
723+
bool ok;
724+
value.mid(2).toFloat(&ok);
725+
if(ok)
726+
{
727+
op = value.left(2);
728+
val = value.mid(2);
729+
numeric = true;
730+
}
721731
}
722732
} else if(value.left(1) == ">" || value.left(1) == "<") {
723733
bool ok;

0 commit comments

Comments
 (0)