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

expose option to filter the features in featureLayer that will return a match #136

Merged
merged 1 commit into from
Sep 14, 2016
Merged

Conversation

jgravois
Copy link
Contributor

resolves #135

L.esri.Geocoding.featureLayerProvider({
  label: 'States',
  url: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3',
  searchFields: ['STATE_NAME'],
  // only return a match if the searched state population exceeds 10 million
  where: 'POP2007 > 10000000'
})

@jgravois jgravois mentioned this pull request Sep 12, 2016
@jgravois jgravois merged commit 9d57887 into Esri:master Sep 14, 2016
@@ -95,7 +95,11 @@ export var FeatureLayerProvider = FeatureLayerService.extend({
queryString.push(field + " LIKE upper('%" + text + "%')");
}

return queryString.join(' OR ');
if (this.options.where) {
return this.options.where + ' AND ' + queryString.join(' OR ');
Copy link

Choose a reason for hiding this comment

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

Enclose queryString.join(' OR ') in parenthesis otherwise it doesn't work as expected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm happy to make the suggested change, but can you clarify exactly what is necessary to generate inappropriate behavior?

everything is working fine on my end.

Copy link

Choose a reason for hiding this comment

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

The issue raises with more than one search field.
The current expression is something like:
IS_ENABLED=1 AND upper(NAME) like ... OR upper(SURNAME) like ...
The one I'd propose is
IS_ENABLED=1 AND (upper(NAME) like ... OR upper(SURNAME) like ... )
The parentheses guarantee the right evaluation order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for holding my hand through that. my brain wasn't firing on all cylinders yesterday so i only tested w/ two distinct words within the search.

resolved by #144.

@jgravois jgravois deleted the where branch September 21, 2016 17:15
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.

provider where option
2 participants