[QGIS-trac] [Quantum GIS] #1876: PostgreSQL text fields become
zero-length strings when blanked on attribute update edits from QGIS
Quantum GIS
qgis at qgis.org
Fri Aug 14 20:36:22 EDT 2009
#1876: PostgreSQL text fields become zero-length strings when blanked on attribute
update edits from QGIS
------------------------------------------------+---------------------------
Reporter: mwtoews | Owner: nobody
Type: bug | Status: new
Priority: major: does not work as expected | Milestone: Version 1.2.0
Component: Data Provider | Version: HEAD
Keywords: | Platform_version:
Platform: All | Must_fix: No
Status_info: 0 |
------------------------------------------------+---------------------------
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
The text field will now have a zero length text value {{{''}}} and not a
NULL value. I have observed zero-length strings "contaminating" my
database, and I can source these oddities to QGIS edits from when someone
blanks out text from fields that previously had non-zero length text.
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.
As a suggested solution, borrow the behaviour from pgAdminIII, whereby an
empty field is always interpreted as NULL, and a zero-length text string
has the literal {{{''}}} (two consecutive single apostrophes). The zero-
length literal should still be available for columns that are text but
cannot be NULL.
--
Ticket URL: <http://trac.osgeo.org/qgis/ticket/1876>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats
More information about the QGIS-trac
mailing list