Skip to content
Permalink
Browse files

Fix value map search widget doesn't work for null/not null searches

before an initial value is picked

Refs #17986
  • Loading branch information
nyalldawson committed Feb 1, 2018
1 parent 4afe967 commit 6fa362b5a22363cfc681b0e20b689ccf823da22c
@@ -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();

@@ -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 )
@@ -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), '')

0 comments on commit 6fa362b

Please sign in to comment.
You can’t perform that action at this time.