arcgis-rest-js icon indicating copy to clipboard operation
arcgis-rest-js copied to clipboard

types(feature-layer): make objectIds optional

Open green3g opened this issue 3 years ago • 2 comments

objectIds is currently required by the IDeleteFeaturesOptions - this should not be the case since you can also use where clauses to delete features.

green3g avatar Oct 12 '21 12:10 green3g

Codecov Report

Merging #925 (459d092) into master (724ae92) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #925   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          140       140           
  Lines         2406      2406           
  Branches       422       422           
=========================================
  Hits          2406      2406           
Impacted Files Coverage Δ
packages/arcgis-rest-feature-layer/src/delete.ts 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 724ae92...459d092. Read the comment docs.

codecov[bot] avatar Oct 12 '21 12:10 codecov[bot]

There is a couple reasons why objectIds is required. First, it's the most commonly used parameter for deleting features. Second, there's no conditional logic in typescript interfaces. Not only can you use where but you can also use geometry to delete features. And when providing geometry you are also are required to provide geometryType and possibly inSR. But one or some combination of the three has to be included to prevent a server error.

I believe you can still use where or geometry with objectIds: [] to make TS happy and still successfully delete features.

Or there would need to be extensive interface splitting to account for all possibilities of parameters that may be passed to deleteFeatures().

I recall this being brought up when the CRUD methods were added to the package but couldn't hunt down the specific comment.

COV-GIS avatar Oct 20 '21 22:10 COV-GIS

Thanks all, and sorry about the delay on this. We'll merge this since setting the type to "optional" is not a breaking change, and then we'll follow-up by creating an issue to re-factor type issue holistically, taking into account some of the things that @COV-GIS mentioned:

  • you can delete via a where or objectIds or geometry (or others too perhaps?)
  • If you pass a geometry you also need to pass a geometry geometryType
  • etc

gavinr avatar Dec 19 '22 22:12 gavinr