salesforce / akita

🚀 State Management Tailored-Made for JS Applications
https://salesforce.github.io/akita/
Apache License 2.0
3.7k stars 342 forks source link

Duplicate entities returned by EntityQuery #1073

Open jvdberg08 opened 12 months ago

jvdberg08 commented 12 months ago

Is this a regression?

No

Description

When using the entityStore.set([x, y]) method, where x and y are duplicates, the store's ids array will contain this id 2 times (ids.push(x[idKey]); ids.push(y[idKey])), while the entities map will only contain the entity once (entities[x[idKey]] = x; entities[y[idKey]] = y).

The entity query's select methods seem to map the ids array to an array of entities by performing a lookup in this map, which causes the entity to be included 2 times, even though it is only present once in the store.

Please provide a link to a minimal reproduction of the bug

https://akita-todos-app-ahgmj4.stackblitz.io

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No