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

(Query -> isSupportedOffline) Check that a value is an object before calling Object.keys #245

Merged
merged 2 commits into from
Mar 29, 2018

Conversation

chrismllr
Copy link
Contributor

@chrismllr chrismllr commented Feb 20, 2018

Description

When utilizing a Cache collection, requests are failing in this function block due to the value being either a string or a boolean, and are being passed into Object.keys.

For some reference, when this issue was encountered, the value for this.filter was:

{ collection: "GenericUser" }

Which is the name of the Cache collection we are calling find on. value, in this case, will equal "GenericUser", which is breaking when being passed to Object.keys.

I haven't done too much digging to see whether this was an issue with how CacheRequest is passing the current query, or if this is just an edge case that should be included in this function.. any insight would be great!

Changes

  • Add a type check to make sure value is an object before calling Object.keys on it.

@thomasconner thomasconner self-requested a review February 21, 2018 15:36
@thomasconner thomasconner self-assigned this Feb 21, 2018
Copy link
Contributor

@thomasconner thomasconner left a comment

Choose a reason for hiding this comment

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

@chrismllr Thanks for the PR! Can you add some unit tests for this change in query.spec.js?

To run the complete suite of unit tests just execute npm test at the root of the project. You can also run a subset of the complete suite of unit tests by executing npm test -- --grep "isSupportedOffline()".

@thomasconner thomasconner merged commit f789271 into Kinvey:master Mar 29, 2018
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