Bug report #11235

Postgis integer field with null values

Added by Pedro Venâncio about 9 years ago. Updated about 9 years ago.

Assignee:Jürgen Fischer
Category:Data Provider/PostGIS
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:19542


When I'm editing PostGIS tables (they are actually related tables) in QGIS, if I leave an 'integer' field of this table as 'null' (blank), QGIS changes the field value to 0, instead of leaving it as 'null'.

This causes me a lot of troubles, since I have some triggers associated with these fields, which being filled with 0, make the triggers run, ending the result with no sense.

A simple test:

1. Create an Integer field in a PostGIS layer;
2. Try to put 0 in this field in any record in the attribute table. Is not possible, the field remains as null;
3. Put the value 1 in the same field, and then put 0. It already works this way;
4. Add the value 0 to a record with another editor;
5. Try to erase this value 0 in QGIS attribute table. If you try to simply delete the 0, QGIS fails, and keeps the 0. However, if you replace the 0 by any other number, and then delete, it already becomes null.

I tested this procedure in Windows with QGIS 1.7.4, 2.0.1-3, 2.2.0-1 and the problem described above does not happen. With QGIS 2.4.0-1 or 2.5, the problem occurs exactly as described, both in Windows and Linux.

It seems a regression so I marked it as blocker.

Associated revisions

Revision 6f84cdce
Added by Matthias Kuhn about 9 years ago

Proper handling of NULL values for edit widgets

  • Photo widget preserves NULL value
  • Web widget preserves NULL value
  • Attribute table can distinguish between 0 and NULL (Fix #11235)


#1 Updated by Matthias Kuhn about 9 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF