Bug report #1876

PostgreSQL text fields become zero-length strings when blanked on attribute update edits from QGIS

Added by Mike Taves about 15 years ago. Updated about 12 years ago.

Status:Closed
Priority:Low
Assignee:Jürgen Fischer
Category:Data Provider
Affected QGIS version:master Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed
Crashes QGIS or corrupts data:No Copied to github as #:11936

Description

This bug is simple to create in QGIS 1.0.x and 1.2.x.

Edit any PostGIS layer with several text fields:
1. Add a geometry feature in QGIS, but leave some text fields blank when adding attributes; commit
1. View database record in another client app (e.g., PgAdminIII) to ensure that blank fields are NULL
1. Edit the feature attributes by adding text to a NULL field;
1. In QGIS, edit the feature attributes, but delete the text; commit

Strictly speaking, this is not a bug, but is in a grey-area leaning toward "feature". Many client apps, like MS Access and pgAdminIII, consider zero-length strings to be NULLs. I prefer this behaviour, since it is consistent to the creation of the features in QGIS when no text has been added to some fields these were inserted as NULLs and not zero-length strings.

Associated revisions

Revision 2db782f4
Added by Jürgen Fischer about 15 years ago

attribute editor fixes:
- fix column misindexing in attribute table, if the geometry column is not last
- fix NULL handling (fixes #1876)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11392 c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision d0c19c5c
Added by Jürgen Fischer about 15 years ago

attribute editor fixes:
- fix column misindexing in attribute table, if the geometry column is not last
- fix NULL handling (fixes #1876)

git-svn-id: http://svn.osgeo.org/qgis/trunk@11392 c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Jürgen Fischer about 15 years ago

Replying to mwtoews:

Strictly speaking, this is not a bug, but is in a grey-area leaning toward "feature".

Well, I consider it a bug. 1. NULL and an empty string are different values. And 2. if you don't touch the value, the value should stay the same.

#2 Updated by Jürgen Fischer about 15 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

#3 Updated by Regis Haubourg about 12 years ago

  • Crashes QGIS or corrupts data set to No
  • Affected QGIS version set to master

Hi,
testing today with 7ce99b8, postgres 9.1, postgis 1.5, I see a regression on that important feature.
Anyone confirms?

#4 Updated by Jürgen Fischer about 12 years ago

  • Pull Request or Patch supplied set to No

regis Haubourg wrote:

testing today with 7ce99b8, postgres 9.1, postgis 1.5, I see a regression on that important feature.

In what way?

#5 Updated by Regis Haubourg about 12 years ago

Sorry,
manually removing a value still writes a zero length string and not a null value..

#6 Updated by Jürgen Fischer about 12 years ago

regis Haubourg wrote:

manually removing a value still writes a zero length string and not a null value..

But that's the intended behaviour. If you enter an empty string, you get an empty string in the database - if you want a null value enter the string representation for NULL (which is configurable in options and NULL by default).

#7 Updated by Regis Haubourg about 12 years ago

OK, got it better. It tried to type 'NULL', but I couldn't make it saved correctly in Postgis. I'm not able to reproduce again.. so it might be related to something else when commiting. I'll test furthermore. You can close the issue and sorry for the noise.

Also available in: Atom PDF