[gdal-dev] Nullable fields in OGR

Frank Warmerdam warmerdam at pobox.com
Thu Feb 18 13:07:00 EST 2010


Jason Roberts wrote:
> Many relational databases allow fields to be set to NULL. Is this 
> supported in OGR? How does one detect whether a field is nullable or not?
> 
>  
> 
> Looking at the class documentation, I see functions 
> OGRFeature::IsFieldSet and OGRFeature::UnsetField. Are these intended 
> for checking whether a field is NULL and setting it to NULL? Or are they 
> used for something else, such as determining which fields have been 
> modified by a caller prior to him calling OGRLayer::SetFeature?
> 
>  
> 
> When I looked at OGRFieldDefn, I could not find a method that might be 
> intended for checking whether a field was nullable (e.g. 
> OGRFieldDefn::IsUnsettable).

Jason,

IsFieldSet() tests if a feature field is NULL, and UnsetField() can force
it to NULL if it is not.

There is currently no way to test if a datastore supports the concept
of NULL fields, but if it does not it should just write a default value
(0.0, empty string, etc).

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list