Skip to content

Empty key or duplicate keys when loading relations #11

@jawadst

Description

@jawadst

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions