-
Notifications
You must be signed in to change notification settings - Fork 479
Closed
Labels
Description
What happened?
According to documentation, the function of multiMerge
is Multiple merging of existing and new values in a batch. Assumes that values are stringified JSON. Once completed, invokes callback with errors (if any).
One expects that the empty object {}
is the identity of the operation of merging objects, and that merging the JSON-ified object "{}"
into any value that is already an object will produce no effect.
This is the case on Android and not the case on iOS (tested with 1.19.3). The following snippet reproduces this, producing '{ "x": 1 }'
for key "a" on Android, and producing '{}'
on iOS.
let { default: { multiMerge, getAllKeys, multiGet } } = require ('@react-native-async-storage/async-storage')
Promise .resolve ()
.then (_ => multiMerge ([ [ 'a', '{ "x": 1 }' ] ] ))
.then (_ => multiMerge ([ [ 'a', '{}' ] ] ))
.then (_ => getAllKeys ())
.then (keys => multiGet (keys))
.then (entries => Object .fromEntries (entries))
.then (result => console .log (result))
The bug is caused by this line
if (RCTMergeRecursive(mergedVal, RCTJSONParse(entry[1], &jsonError))) { |
Line 61 in 9d9bb1a
JSONObject(oldEntry.value).mergeWith(JSONObject(newEntry.value)).toString() |
Version
1.19.3
What platforms are you seeing this issue on?
- Android
- iOS
- macOS
- Windows
- web
System Information
.
Steps to Reproduce
Provided above