Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5968 closed defect (fixed)

Empty elements in GML : empty or NULL

Reported by: Even Rouault Owned by: Even Rouault
Priority: normal Milestone: 2.0.0
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: gml wfs null
Cc:

Description (last modified by Even Rouault)

From http://lists.osgeo.org/pipermail/gdal-dev/2015-May/041834.html :

> $ ogr2ogr -f 'GPKG' out.gpkg WFS:http://maps.zh.ch/wfs/TbaBaustellenZHWF
> S
> ERROR 1: failed to execute insert : NOT NULL constraint failed:
> baustellen-detailansicht.weiteregemeinden
> ERROR 1: Unable to write feature 518 from layer baustellen-detailansicht .
> ERROR 1: Terminating translation prematurely after failed translation
> of layer baustellen-detailansicht (use -skipfailures to skip errors)

My analysis

This is an interesting feedback...

The issue is that OGR interprets the following 

        <ms:weiteregemeinden></ms:weiteregemeinden>

as being NULL, instead of empty string.
And the schema of the layer as defined by http://maps.zh.ch/wfs/TbaBaustellenZHWFS?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=baustellen-detailansicht makes the attribute mandatory, hence NOT NULL.

Presumably the cleaner way of addressing this would be to make the GML driver report an empty string, instead of NULL, but I still think that the intent is generally NULL and this was the historic behaviour, so I'm hesitant to change this.

So in light of this, I've reconsidered the introduction of not-nullable fields in GML/WFS drivers, and just disabled them by default to avoid such issues

Change History (3)

comment:1 by Even Rouault, 9 years ago

Description: modified (diff)

comment:2 by Even Rouault, 9 years ago

Milestone: 2.0
Resolution: fixed
Status: newclosed

trunk r29214 "GML/WFS: by default does not advertize NOT NULL fields since we treat empty strings as being null for historical reasons. By setting the open option EMPTY_AS_NULL=NO, empty strings will be reported as such and NOT NULL fields might be advertized (#5968)"

trunk r29215 "GML: update test for #5968"

comment:3 by Even Rouault, 9 years ago

Milestone: 2.02.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.