Skip to content

Commit

Permalink
Fix inconsistent args with FeatureLayerMetadata.create and QueryField…
Browse files Browse the repository at this point in the history
…s.create (#241)

* Fix ids in layers metadata. (#240)

* Fix params passed to QueryFields.create.
  • Loading branch information
schmidtk authored Sep 14, 2022
1 parent ff749a5 commit ca878e4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
### Fixed
- geojson validation security vulnerablity
- fix ids in layers metadata
- fix params passed to QueryFields.create

## [4.0.1] - 08-05-2022
### Changed
Expand Down
4 changes: 3 additions & 1 deletion lib/helpers/table-layer-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class TableLayerMetadata {

const {
params: {
layer: layerId
layer: reqLayer
} = {},
query = {}
} = req

const layerId = reqLayer != null ? reqLayer : req.layerId

const {
currentVersion,
fullVersion,
Expand Down
2 changes: 1 addition & 1 deletion lib/query/render-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function renderFeaturesResponse (data = {}, params = {}) {
const computedProperties = {
geometryType: params.geometryType,
spatialReference: getOutputSpatialReference(data, params),
fields: QueryFields.create({ data, ...params }),
fields: QueryFields.create({ ...data, ...params }),
features: data.features || [],
exceededTransferLimit: !!limitExceeded,
objectIdFieldName: idField || objectIdFieldNameDefault,
Expand Down
2 changes: 1 addition & 1 deletion lib/queryRelatedRecords.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function queryRelatedRecords (data, params = {}) {
relatedRecordGroups: []
}

if (!params.returnCountOnly) response.fields = QueryFields.create(data, params)
if (!params.returnCountOnly) response.fields = QueryFields.create({ ...data, ...params })

const geomType = getGeometryTypeFromGeojson(data)
if (geomType) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/query/render-features.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('renderFeaturesResponse', () => {
exceededTransferLimit: false
})
createQueryFieldsSpy.callCount.should.equal(1)
createQueryFieldsSpy.firstCall.args.should.deepEqual([{ data: json, geometryType: 'esriGeometryPoint' }])
createQueryFieldsSpy.firstCall.args.should.deepEqual([{ ...json, geometryType: 'esriGeometryPoint' }])
getCollectionCrsSpy.callCount.should.equal(1)
getCollectionCrsSpy.firstCall.args.should.deepEqual([json])
normalizeSpatialReferenceSpy.callCount.should.equal(1)
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('renderFeaturesResponse', () => {
transform: 'transform'
})
createQueryFieldsSpy.callCount.should.equal(1)
createQueryFieldsSpy.firstCall.args.should.deepEqual([{ data: json, geometryType: 'esriGeometryPoint' }])
createQueryFieldsSpy.firstCall.args.should.deepEqual([{ ...json, geometryType: 'esriGeometryPoint' }])
getCollectionCrsSpy.callCount.should.equal(1)
getCollectionCrsSpy.firstCall.args.should.deepEqual([json])
normalizeSpatialReferenceSpy.callCount.should.equal(1)
Expand Down

0 comments on commit ca878e4

Please sign in to comment.