-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Describe the bug
In the function below, the line layer.container.manager.update_definition(lyrdef.as_json()) tries to perform an update on the FeatureLayerCollection container of the layer. This will result in the error code 500, Field 'fields' cannot be updated. as the "fields" value is not an updateable value in the FeatureLayerCollection.
class ViewManager:
def update(self, layer_def: list[ViewLayerDefParameter] | None = None) -> bool:
"""
Updates a view definition with new queries, geometries, and column
visibilities.
============= =====================================================
**Argument** **Description**
------------- -----------------------------------------------------
layer_def List of
:class:`~arcgis.gis._impl._dataclasses.ViewLayerDefParameter`
objects for modifying the layers.
============= =====================================================
:returns: Boolean
"""
results = []
assert isinstance(layer_def, (list, tuple))
for lyrdef in layer_def:
assert isinstance(lyrdef, ViewLayerDefParameter)
layer = lyrdef.layer
assert isinstance(layer, arcgis.features.FeatureLayer)
if "isView" in lyrdef.layer.properties and lyrdef.layer.properties.isView:
results.append(
{
layer._url: layer.container.manager.update_definition(
lyrdef.as_json()
)
}
)
else:
raise ValueError("The layer is not a view.")
del lyrdef
return resultsTo Reproduce
Steps to reproduce the behavior:
view_item = gis.content.get("item_id")
view_manager = view_item.view_manager
layer_defs = view_manager.get_definitions(view_item)
view_manager.update(layer_defs)error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "..\Lib\site-packages\arcgis\features\managers.py", line 3206, in update_definition
res = self._con.post(u_url, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "..\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 1529, in post
return self._handle_response(
^^^^^^^^^^^^^^^^^^^^^^
File "..\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 986, in _handle_response
raise Exception(data["error"])
Exception: {'code': 500, 'message': "Field 'fields' cannot be updated.", 'details': []}Expected behavior
The update should be directly on the layer itself without accessing the container value layer.manager.update_definition(lyrdef.as_json()):
def update(self, layer_def: list[ViewLayerDefParameter] | None = None) -> bool:
"""
Updates a view definition with new queries, geometries, and column
visibilities.
============= =====================================================
**Argument** **Description**
------------- -----------------------------------------------------
layer_def List of
:class:`~arcgis.gis._impl._dataclasses.ViewLayerDefParameter`
objects for modifying the layers.
============= =====================================================
:returns: Boolean
"""
results = []
assert isinstance(layer_def, (list, tuple))
for lyrdef in layer_def:
assert isinstance(lyrdef, ViewLayerDefParameter)
layer = lyrdef.layer
assert isinstance(layer, arcgis.features.FeatureLayer)
if "isView" in lyrdef.layer.properties and lyrdef.layer.properties.isView:
results.append(
{
layer._url: layer.manager.update_definition(
lyrdef.as_json()
)
}
)
else:
raise ValueError("The layer is not a view.")
del lyrdef
return resultsPlatform (please complete the following information):
- OS: Windows
- Python API Version 2.4.1