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

Empty key or duplicate keys when loading relations #11

Open
jawadst opened this issue Aug 28, 2017 · 1 comment
Open

Empty key or duplicate keys when loading relations #11

jawadst opened this issue Aug 28, 2017 · 1 comment

Comments

@jawadst
Copy link

jawadst commented Aug 28, 2017

When loading relations (I have been using belongsTo relations mostly), js-data-adapter does not check for empty or duplicate keys before calling findAll (example for belongsTo: https://github.com/js-data/js-data-adapter/blob/release/src/index.js#L817).

This results in cases where:

  • The findAll function is called with an empty where.in array
  • The findAll function is called with duplicates in the where.in array

These two cases are -at best- very inefficient or problematic depending on the actual adapter being used and the endpoints (ex: the js-data-http might fail because an API is not expecting an empty in clause or duplicated).

I have my own adapter that extends js-data-adapter so I have played with fixes and simply filtering out duplicates or not calling findAll if keys is empty works well.
I can work on a PR if you would accept it.

@jawadst jawadst changed the title Empty key or duplicate keys Empty key or duplicate keys when loading relations Aug 28, 2017
@crobinson42
Copy link
Member

@jawadst we're working on a v4 release - If you're interested in contributing on this issue with a PR there is already a branch rewritten in TS, v4. 👍🏼

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 a pull request may close this issue.

2 participants