Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent date fields from being add to response when not requested #62

Merged
merged 2 commits into from
Apr 3, 2018

Conversation

rgwozdz
Copy link
Member

@rgwozdz rgwozdz commented Mar 29, 2018

Discovered that date fields were being add to response payloads even in cases where said date fields were excluded by use of the outFields query parameter. This caused unwanted drawing/rendering effects in ArcGIS Pro.

Also discovered that outFields arriving as a comma delimited string were not being parsed properly in Winnow queries.

This PR includes a fix to parse the outFields input if comma-delimited, and additional checks to include date fields in response payloads only when specifically requested with outFields query param (or when outFields=*).

…lready handled separately in FeatureServer when producing `fields` response parameter; but it occurs *after* the call to winnow and currently does not persist the array transformation to the options object.
…n the field name is one of the requested `outFields`.
function normalizeFields (options) {
const fields = options.fields || options.outFields
if (fields === '*') return undefined
return typeof fields === 'string' ? [fields] : fields
if (typeof fields === 'string' || fields instanceof String) return fields.split(',')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a scenario where fields would not be type string but also an instance of String? Is that some JS weirdness that can happen with prototypes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably overkill here, but that can happen when a string is created with new String('Some text'), which has type Object. Check it out console.log(typeof new String("test")). So I usually default to string checking like this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, Javascript, is there nothing you can't make confusing?

Copy link

@trescube trescube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and hooray for added comments!

@rgwozdz rgwozdz merged commit 0f5b38e into master Apr 3, 2018
@rgwozdz rgwozdz deleted the date-field-mgmt branch April 3, 2018 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants