data icon indicating copy to clipboard operation
data copied to clipboard

Store.query does not respect empty arrays

Open stavalon-auditboard opened this issue 3 years ago • 1 comments

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.

stavalon-auditboard avatar Oct 14 '21 21:10 stavalon-auditboard

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.

snewcomer avatar Oct 16 '21 12:10 snewcomer

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.

runspired avatar Sep 03 '23 22:09 runspired