Bug report #1876
PostgreSQL text fields become zero-length strings when blanked on attribute update edits from QGIS
|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|
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.
#1 Updated by Jürgen Fischer about 10 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.
#6 Updated by Jürgen Fischer almost 7 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 almost 7 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.