Bug report #12167
Expression-selected labels doesn't deal with NULL
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | |||
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.
Associated revisions
Fix #12167 - Handle nulls in show label property for labels
Funded by Digital Mapping Solutions
History
#1
Updated by Nathan Woodrow over 9 years ago
and the expression is "fieldname" = 'value'
correct?
#2
Updated by Corey Burger over 9 years ago
Yes, exactly that. Sorry, should have pointed that out. It appears to happen with both string and whole number fields.
#4
Updated by Giovanni Manghi over 9 years ago
- Status changed from Open to Feedback
- Category set to Labelling
#5
Updated by Corey Burger over 9 years ago
yes, exactly like that
#6
Updated by Nathan Woodrow over 9 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 over 9 years ago
- File LabelTest.zip added
Attached a zip file with a test shp file and project
#8
Updated by Nathan Woodrow over 9 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 over 9 years ago
- Status changed from Feedback to Closed
Fixed in changeset a15aa74bb7e4b457b67624882413b72b2e862cd6.