From a2a2e0e57c8d0f82dd849eff925c0ae603595b63 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:19:03 +0100 Subject: [PATCH] Fix editing for pk not integer. (#763) (#765) * Fix editing for pk not integer. * Check default value as nextval(NULL). --------- Co-authored-by: wlorenzetti (cherry picked from commit 36c20bef0fb0ee3f537e80484eaf3ff34040e98b) --- g3w-admin/core/api/base/vector.py | 5 +++-- g3w-admin/core/utils/structure.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/g3w-admin/core/api/base/vector.py b/g3w-admin/core/api/base/vector.py index 079c36959..a7365d15d 100644 --- a/g3w-admin/core/api/base/vector.py +++ b/g3w-admin/core/api/base/vector.py @@ -2,6 +2,7 @@ import deprecation from qgis.core import QgsWkbTypes +from core.utils.qgisapi import get_layer_fids_from_server_fids class MetadataVectorLayer(object): """ @@ -33,5 +34,5 @@ def get_feature(self, pk): """ Returns a (possibly invalid) single feature from QGIS layer """ - - return self.qgis_layer.getFeature(int(pk)) + pk = get_layer_fids_from_server_fids([str(pk)], self.qgis_layer)[0] + return self.qgis_layer.getFeature(pk) diff --git a/g3w-admin/core/utils/structure.py b/g3w-admin/core/utils/structure.py index f4505a663..b8feb6f96 100644 --- a/g3w-admin/core/utils/structure.py +++ b/g3w-admin/core/utils/structure.py @@ -247,6 +247,7 @@ def mapLayerAttributesFromQgisLayer(qgis_layer, **kwargs): field.constraints().constraintStrength( QgsFieldConstraints.ConstraintExpression) == QgsFieldConstraints.ConstraintStrengthHard default_clause = data_provider.defaultValueClause(field_index) + default_clause = default_clause if default_clause != 'nextval(NULL)' else '' # default value for editing from qgis_layer if 'default' not in kwargs: