Bug report #7554

field calculator save wrong values when field width isn't enough

Added by John Sankey over 6 years ago. Updated 8 months ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Expressions
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:16496

Description

Using the field calculator from the attribute table, the $area of each feature is shown in the table as float (whether the result asked for is integer or decimal). If the size of the target field is less than 10 decimal places plus decimal point plus the actual maximum number of digits plus at least one to spare, the values are replaced by NULL on save.

The best resolution would be to use internal working space for the float rather than the shape file attribute table space so valid results would be saved as expected i.e. 6 digit results would fit into a 6 width integer field.

Another option might be to not allow the field width to be decreased below the minimum required for results to be saved.

History

#1 Updated by Jürgen Fischer over 5 years ago

  • Category set to Expressions

#2 Updated by Giovanni Manghi over 5 years ago

  • Affected QGIS version changed from 1.8.0 to master
  • OS version deleted (10.6.8)
  • Operating System deleted (Mac OSX)
  • Target version set to Version 2.4
  • Subject changed from field calculator NULLs valid values to field calculator save wrong values when field width isn't enough

it seems that now it is slightly different but always wrong:

no NULL values are saved into the table, but instead the integer part of results get truncated and the decimal part become all 0.

#3 Updated by Jürgen Fischer over 5 years ago

  • Target version changed from Version 2.4 to Future Release - High Priority

#4 Updated by Giovanni Manghi over 2 years ago

  • Easy fix? set to No
  • Regression? set to No

#5 Updated by Giovanni Manghi 8 months ago

  • Status changed from Open to Closed
  • Resolution set to end of life

Also available in: Atom PDF