Bug report #15614

Error when adding integer field to an existing geopackage

Added by Jérôme Guélat over 7 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:Even Rouault
Category:Data Provider/OGR
Affected QGIS version:2.16.3 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:23537

Description

There is a problem when adding an integer field to an existing geopackage. Here are some steps to reproduce the bug:

1. Create a new geopackage
2. Start editing and create a new empty integer field using the "New field" button (attribute table)
3. Stop editing and try to save changes, I get the following error message:

Could not commit changes to layer testshape

Errors: SUCCESS: 1 attribute(s) added.
ERROR: field with index 2 is not the same!
Provider: ogr
Storage: GPKG
expected field: name=test type=int typeName=integer len=1 precision=0
retrieved field: name=test type=int typeName=Integer len=0 precision=0

Associated revisions

Revision bb9c75b3
Added by Even Rouault over 7 years ago

[OGR provider] Make addAttributes() return the requested field type, precision and width so as to make QgsVectorLayerEditBuffer::commitChanges() API

Fixes #15614

Revision d0774e62
Added by Even Rouault over 7 years ago

[OGR provider] Make addAttributes() return the requested field type, precision and width so as to make QgsVectorLayerEditBuffer::commitChanges() API

Fixes #15614

Revision 38a77118
Added by Even Rouault over 7 years ago

[OGR provider] Make addAttributes() return the requested field type, precision and width so as to make QgsVectorLayerEditBuffer::commitChanges() API

Fixes #15614

Revision 8cf03ced
Added by Even Rouault over 7 years ago

[OGR provider] Make addAttributes() return the requested field type, precision and width so as to make QgsVectorLayerEditBuffer::commitChanges() API

Fixes #15614

History

#1 Updated by Jérôme Guélat over 7 years ago

This bug is still present in QGIS 2.18... It also happens with other types (text columns seem to be OK, though).

#2 Updated by Even Rouault over 7 years ago

  • Status changed from Open to Closed

#3 Updated by Even Rouault over 7 years ago

  • Resolution set to fixed/implemented
  • Target version set to Version 2.14
  • Assignee set to Even Rouault
  • Category set to Data Provider/OGR

This was due to the create field dialog asking to create fields with width 1, whereas the GPKG driver doesn't support field width for non-text field, and the QgsVectorLayerEditBuffer class checking that the created field has the asked width.

Also available in: Atom PDF