[Qgis-developer] QgsField::length semantic

Sandro Santilli strk at kbt.io
Tue Oct 11 01:45:18 PDT 2016


Chasing a regression bug upon importing shapefile to postgresql [1]
I've stumbled upon an unclear semantic of the "length" member of
QgsField class [2].

The Ogr provider, upon loading shapefiles, uses the DBF field width
_minus_one_, for reasons that are unknown to me. Upon writing a layer
to PostgreSQL, the missing _one_ results in values being too large
for the field size.

So the solution to this bug seems to be a clear definition of what
QgsField::length is supposed to be, beacuse either Ogr provider is
doing a mistake in reducing that field by 1 or PostgreSQL provider
is doing a mistake in NOT augmenting that field by 1.

Does anyone have an idea about how should QgsField::length be
interpreted ?


[1] http://hub.qgis.org/issues/15188
[2] https://qgis.org/api/classQgsField.html#a8490cd90a5089a7f04bb97c725e54be9

--strk; 

  ()   Free GIS & Flash consultant/developer
  /\   https://strk.kbt.io/services.html


More information about the Qgis-developer mailing list