Skip to content

Commit

Permalink
Fix editing for pk not integer. (#763) (#765)
Browse files Browse the repository at this point in the history
* Fix editing for pk not integer.

* Check default value as nextval(NULL).

---------

Co-authored-by: wlorenzetti <[email protected]>
(cherry picked from commit 36c20be)
  • Loading branch information
github-actions[bot] committed Feb 22, 2024
1 parent 705f471 commit a2a2e0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions g3w-admin/core/api/base/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions g3w-admin/core/utils/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a2a2e0e

Please sign in to comment.