Bug report #12167

Expression-selected labels doesn't deal with NULL

Added by Corey Burger about 5 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:Larry Shaffer
Category:Labelling
Affected QGIS version:2.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:20360

Description

If you are attempting to limit labels based on a field that contains NULL values, any attempt to select on that field will fail.

Steps to reproduce:
1. Use "Show Only" and select a field with NULL values
2. Observe that all rows appear to be being labelled
3. Change NULL values to another value
4. Observe that labelling rules now appear to be correctly handled

This appears to be a bug with the labelling engine, as the selection process works otherwise.

testy.png (42 KB) Nathan Woodrow, 2015-02-09 11:06 PM

LabelTest.zip (4.54 KB) Corey Burger, 2015-02-10 01:28 PM

Associated revisions

Revision a15aa74b
Added by Nathan Woodrow about 5 years ago

Fix #12167 - Handle nulls in show label property for labels

Funded by Digital Mapping Solutions

History

#1 Updated by Nathan Woodrow about 5 years ago

and the expression is "fieldname" = 'value' correct?

#2 Updated by Corey Burger about 5 years ago

Yes, exactly that. Sorry, should have pointed that out. It appears to happen with both string and whole number fields.

#3 Updated by Nathan Woodrow about 5 years ago

Like that?

#4 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Open to Feedback
  • Category set to Labelling

#5 Updated by Corey Burger about 5 years ago

yes, exactly like that

#6 Updated by Nathan Woodrow about 5 years ago

I don't see that here. Can you attach a project with sample data please to test with.

#7 Updated by Corey Burger about 5 years ago

Attached a zip file with a test shp file and project

#8 Updated by Nathan Woodrow about 5 years ago

  • Assignee set to Larry Shaffer

This seems to be related to the way the data defined values are handled.

// data defined show label? defaults to show label if not 0
  if ( dataDefinedEvaluate( QgsPalLayerSettings::Show, exprVal ) )
  {
    QgsDebugMsgLevel( QString( "exprVal Show:%1" ).arg( exprVal.toBool() ? "true" : "false" ), 4 );
    if ( !exprVal.toBool() )
    {
      return;
    }
  }

dataDefinedEvaluate will return false if the result is null but also if the property isn't set, so there is no way to tell between a null value because it's not set and a null value because it is a null result.

#9 Updated by Anonymous about 5 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF