upsertEntities misleading name #447
strigefleur
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As per docs
upsertEntities
will perform a merge:Any partial entities will be merged with the existing ones
.So, you may end up in situation where the store contains
{ id: 1, permanentProp: 'alwaysHere', nullableProp: 'sometimesHere' }
and pending entity is
{ id: 1, permanentProp: 'alwaysHere123' }
and then
upsertEntities
merge both resulting in a false entity state{ id: 1, permanentProp: 'alwaysHere123', nullableProp: 'sometimesHere' }
whereas expected entity state is
{ id: 1, permanentProp: 'alwaysHere123' }
.This works as intended as the documents say.
Though database experience tells it should not be
I insert if not found, I merge if found
but ratherI insert if not found, I overwrite if found
. Actual behavior sounds more likemergesert
thanupsert
.I'd suggest either rename the method to match it's purpose or add some kind of
upsertStrategy = 'merge' | 'overwrite'
as an option to the method call.Beta Was this translation helpful? Give feedback.
All reactions