File tree Expand file tree Collapse file tree 3 files changed +10
-12
lines changed
android/src/main/java/com/reactnativecommunity/asyncstorage Expand file tree Collapse file tree 3 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,11 @@ public class AsyncStorageErrorUtil {
30
30
}
31
31
32
32
/* package */ static WritableMap getInvalidKeyError (@ Nullable String key ) {
33
- return getError (key , "Invalid key" );
33
+ return getError (key , "Invalid key - expected string. " );
34
34
}
35
35
36
36
/* package */ static WritableMap getInvalidValueError (@ Nullable String key ) {
37
- return getError (key , "Invalid Value" );
37
+ return getError (key , "Invalid Value - expected string. " );
38
38
}
39
39
40
40
/* package */ static WritableMap getDBError (@ Nullable String key ) {
Original file line number Diff line number Diff line change @@ -218,23 +218,21 @@ protected void doInBackgroundGuarded(Void... params) {
218
218
for (int idx =0 ; idx < keyValueArray .size (); idx ++) {
219
219
if (keyValueArray .getArray (idx ).size () != 2 ) {
220
220
error = AsyncStorageErrorUtil .getInvalidValueError (null );
221
- return ;
222
221
}
223
222
if (keyValueArray .getArray (idx ).getString (0 ) == null ) {
224
223
error = AsyncStorageErrorUtil .getInvalidKeyError (null );
225
- return ;
226
224
}
227
225
if (keyValueArray .getArray (idx ).getString (1 ) == null ) {
228
226
error = AsyncStorageErrorUtil .getInvalidValueError (null );
229
- return ;
230
227
}
231
-
232
- statement .clearBindings ();
233
- statement .bindString (1 , keyValueArray .getArray (idx ).getString (0 ));
234
- statement .bindString (2 , keyValueArray .getArray (idx ).getString (1 ));
235
- statement .execute ();
228
+ if (error == null ) {
229
+ statement .clearBindings ();
230
+ statement .bindString (1 , keyValueArray .getArray (idx ).getString (0 ));
231
+ statement .bindString (2 , keyValueArray .getArray (idx ).getString (1 ));
232
+ statement .execute ();
233
+ mReactDatabaseSupplier .get ().setTransactionSuccessful ();
234
+ }
236
235
}
237
- mReactDatabaseSupplier .get ().setTransactionSuccessful ();
238
236
} catch (Exception e ) {
239
237
FLog .w (ReactConstants .TAG , e .getMessage (), e );
240
238
error = AsyncStorageErrorUtil .getError (null , e .getMessage ());
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ type MultiRequest = {|
53
53
| } ;
54
54
55
55
function checkValueTypeNotString ( value : any , usedKey : string ) {
56
- if ( typeof value !== 'string' ) {
56
+ if ( value && typeof value !== 'string' ) {
57
57
console . warn (
58
58
`[AsyncStorage] The value for key "${ usedKey } " is not a string. This can lead to unexpected behavior/errors. Consider stringifying it.` ,
59
59
) ;
You can’t perform that action at this time.
0 commit comments