Skip to content

Commit

Permalink
Fix value map search widget doesn't work for null/not null searches
Browse files Browse the repository at this point in the history
before an initial value is picked

Refs #17986
  • Loading branch information
nyalldawson committed Feb 1, 2018
1 parent 4afe967 commit 6fa362b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/gui/editorwidgets/qgsvaluemapsearchwidgetwrapper.cpp
Expand Up @@ -80,10 +80,6 @@ QgsSearchWidgetWrapper::FilterFlags QgsValueMapSearchWidgetWrapper::defaultFlags

QString QgsValueMapSearchWidgetWrapper::createExpression( QgsSearchWidgetWrapper::FilterFlags flags ) const
{
//if deselect value, always pass
if ( mComboBox->currentIndex() == 0 )
return QString();

//clear any unsupported flags
flags &= supportedFlags();

Expand All @@ -95,6 +91,10 @@ QString QgsValueMapSearchWidgetWrapper::createExpression( QgsSearchWidgetWrapper
if ( flags & IsNotNull )
return fieldName + " IS NOT NULL";

//if deselect value, always pass
if ( mComboBox->currentIndex() == 0 )
return QString();

QString currentKey = mComboBox->currentData().toString();

switch ( fldType )
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgssearchwidgetwrapper.py
Expand Up @@ -142,8 +142,8 @@ def testCreateExpression(self):
# first, set it to the "select value" item
c.setCurrentIndex(0)

self.assertEqual(w.createExpression(QgsSearchWidgetWrapper.IsNull), '')
self.assertEqual(w.createExpression(QgsSearchWidgetWrapper.IsNotNull), '')
self.assertEqual(w.createExpression(QgsSearchWidgetWrapper.IsNull), '"fldtxt" IS NULL')
self.assertEqual(w.createExpression(QgsSearchWidgetWrapper.IsNotNull), '"fldtxt" IS NOT NULL')
self.assertEqual(w.createExpression(QgsSearchWidgetWrapper.EqualTo), '')
self.assertEqual(w.createExpression(QgsSearchWidgetWrapper.NotEqualTo), '')

Expand Down

0 comments on commit 6fa362b

Please sign in to comment.