fix(OGRProvider_init): make the 'id_field' attribute mandatory in provider config (#1135)

As for the 'layer' attribute, the 'id_field' should be specified in the
configuration file for the OGRProvider. The 'get' method of a OGRProvider
instance (e.g. when requesting a single feature) needs the feature ID when
setting an attribute filter on the layer. If the 'id_field' attribute is
omitted in the configuration file, the error thrown is more explicit.
This commit is contained in:
Mathieu Tachon
2023-02-10 21:06:23 +01:00
committed by GitHub
parent 30f279b7ad
commit 7f047348b5
+7
View File
@@ -171,6 +171,13 @@ class OGRProvider(BaseProvider):
self._load_source_helper(self.data_def['source_type'])
# ID field is required
self.id_field = provider_def.get('id_field')
if not self.id_field:
msg = 'Need explicit \'id_field\' attr in provider config'
LOGGER.error(msg)
raise Exception(msg)
# Layer name is required
self.layer_name = provider_def.get('layer')
if not self.layer_name: