Bug report #19981

Value relation, value 0 = NULL

Added by Casper Bertelsen over 5 years ago. Updated over 5 years ago.

Assignee:Alessandro Pasotti
Category:Edit widget
Affected QGIS version:3.2.3 Regression?:No
Operating System:Windows 10 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27803


I have a value of 0 in a column of data type integer.

The column is set to widget type "Value relation", relating to a table having descriptions for each possible value. However if I tick Allow NULL value, existing objects having value 0 are shown as (No selection) instead of the proper value from the drop down relating to value 0.

Relating to the issue, testing it further:
- When the form shows after digitizing the Value relation widget is completely blank by default when Allow NULL value is on. However sometimes it is set to (No selection) by default I haven't been able to find out when it does that and when it doesn't. - But couldn't this be case either way that the default value in the drop down is (No selection) when no other default value has been set?

- When default value is set to 0, the default value is (No selection) instead of the value 0 from the drop-down.

zero_null.zip (53.7 KB) Casper Bertelsen, 2018-10-01 08:19 AM

Associated revisions

Revision 6574e692
Added by Alessandro Pasotti over 5 years ago

Fixes value relation widget 0 indexed related items

Fixes #19981 - Value relation, value 0 = NULL


#1 Updated by Alessandro Pasotti over 5 years ago

It would be great if you could attach a minimal project to reproduce the issue.

#2 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

#3 Updated by Casper Bertelsen over 5 years ago

Sure, i have exported two tables into a geopackage (originally from postgres). One polygon layer as well as a layer without geometry (look up). In the project I have linked to the polygon layer twice, so it’s easy to see the actual value as well as how it results using value relation.

As you can see the existing polygon is set to no selection even though it has the value 0, represented in the look up-table. If you digitize a new polygon, I have set the relation to default to zero however this results in no selection by default.

#4 Updated by Alessandro Pasotti over 5 years ago

  • Assignee set to Alessandro Pasotti

Thanks for the report and the test project, I'll have a look ASAP!

#5 Updated by Anonymous over 5 years ago

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed

Also available in: Atom PDF