[QGIS-Developer] GPKG and FID -- can we fix this mess?

techdude1996 techrules08041 at yahoo.com
Mon Oct 19 06:59:57 PDT 2020


uclaros wrote
> Given two layers, A and B, there are two cases of merge:
> - B is inserted into A: A features keep their fid values, B features get a
> new one on insert.
> - A and B are inserted into C: Both A and B features get new fids on
> insert.
> 
> This is at least what I expect from an autogenerated, not null, unique
> field.
> 
> --
> Sent from:
> http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
> _______________________________________________
> QGIS-Developer mailing list

> QGIS-Developer at .osgeo

> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

I agree. I do believe that when a new GPKG table is created, a sequence is
created for the FID column. When there are inserts done onto the table, the
next sequence value is given for that field. If this is the case, in QGIS
the FID field should be read-only. If you wish to hide it by default, that
is fine. Just make sure that it can be turned visible. With that said, the
quote above should happen. When copying and pasting features, the FID field
should be ignored and a new FID value given to the pasted feature. This is
what I expect with an auto-generated field.

To answer the original question about gml, a field-mapping option would be
nice when exporting features, allowing you to change the name of the output
fields if desired. Logic could be added to the data provider that when
creating a new GPKG layer, if a field name already exists named FID that
does not match the integer type and/or unique constraint, the new integer
primary key field is created named ogc_fid or something along those lines.
If the existing named field field is a unique integer field, that column can
be used. I'm not sure if a sequence can be initialized with a starting
value, but if it can, just set it to MAX(fid) + 1.

-- Ethan



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html


More information about the QGIS-Developer mailing list