data
data copied to clipboard
Store.query does not respect empty arrays
Description
When providing a parameter with an empty array to the ember-store query function the resulting url completely omits the parameter.
Expected:
store.query('user', {ids: []}) => /users?ids=[]
Unexpected:
store.query('user', {ids: []}) => /users
Versions
├─ @ember-data/[email protected]
├─ [email protected]
└─ [email protected]
✨ Done in 1.29s.
Thank you! Yes this does seem to be the case. Moreover, with recent-ish stances on how to handle empty fields
and includes
https://jsonapi.org/format/#fetching-sparse-fieldsets
The JSONAPI has taken a strict stance on what an empty query param should mean. They stated it should return no fields instead of leaving it up to the implementer.
Also see here
https://github.com/json-api/json-api/pull/1532
An empty value indicates that no related resources should be returned.
The fix, as you indicated, should make sure the ids
qp is included in the eventual url.
Closing as we're moving away from adapters and don't wish to change their semantics. The request utils / request-manager do not exhibit this issue.