@react-native-firebase/firestore 13.1.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [14.0.0](https://github.com/invertase/react-native-firebase/compare/v13.1.1...v14.0.0) (2021-12-14)
7
+
8
+ - fix(firestore)!: fix Long/Double conversion issues #3004 (#5840) ([910d4e4](https://github.com/invertase/react-native-firebase/commit/910d4e420b62b5bcc67bbb1b77b9485ae2662119)), closes [#3004](https://github.com/invertase/react-native-firebase/issues/3004) [#5840](https://github.com/invertase/react-native-firebase/issues/5840) [#3004](https://github.com/invertase/react-native-firebase/issues/3004)
9
+
10
+ ### BREAKING CHANGES
11
+
12
+ - Previous versions of firestore here incorrectly saved integers as doubles on iOS, so they did not show up in `where`/`in` queries. You had to save numbers as strings if you wanted `where`/`in` queries to work cross-platform. Number types will now be handled correctly. However, If you have integers saved (incorrectly!) as double (from previous versions) and you use where / in style queries on numbers, then the same document will no longer be found via .where. Mitigation could be to go through your whole DB and load and re-save the integers correctly, or alter queries. Please test your where / in queries that use number types if this affects you.
13
+
6
14
  ## [13.1.1](https://github.com/invertase/react-native-firebase/compare/v13.1.0...v13.1.1) (2021-12-14)
7
15
 
8
16
  ### Bug Fixes
@@ -60,7 +60,7 @@ public class ReactNativeFirebaseFirestoreSerialize {
60
60
  private static final int INT_DOCUMENTID = 4;
61
61
  private static final int INT_BOOLEAN_TRUE = 5;
62
62
  private static final int INT_BOOLEAN_FALSE = 6;
63
- private static final int INT_NUMBER = 7;
63
+ private static final int INT_DOUBLE = 7;
64
64
  private static final int INT_STRING = 8;
65
65
  private static final int INT_STRING_EMPTY = 9;
66
66
  private static final int INT_ARRAY = 10;
@@ -70,6 +70,8 @@ public class ReactNativeFirebaseFirestoreSerialize {
70
70
  private static final int INT_BLOB = 14;
71
71
  private static final int INT_FIELDVALUE = 15;
72
72
  private static final int INT_OBJECT = 16;
73
+ private static final int INT_INTEGER = 17;
74
+ private static final int INT_NEGATIVE_ZERO = 18;
73
75
  private static final int INT_UNKNOWN = -999;
74
76
 
75
77
  // Keys
@@ -300,7 +302,7 @@ public class ReactNativeFirebaseFirestoreSerialize {
300
302
  }
301
303
 
302
304
  if (value instanceof Integer) {
303
- typeArray.pushInt(INT_NUMBER);
305
+ typeArray.pushInt(INT_DOUBLE);
304
306
  typeArray.pushDouble(((Integer) value).doubleValue());
305
307
  return typeArray;
306
308
  }
@@ -325,19 +327,19 @@ public class ReactNativeFirebaseFirestoreSerialize {
325
327
  return typeArray;
326
328
  }
327
329
 
328
- typeArray.pushInt(INT_NUMBER);
330
+ typeArray.pushInt(INT_DOUBLE);
329
331
  typeArray.pushDouble(doubleValue);
330
332
  return typeArray;
331
333
  }
332
334
 
333
335
  if (value instanceof Float) {
334
- typeArray.pushInt(INT_NUMBER);
336
+ typeArray.pushInt(INT_DOUBLE);
335
337
  typeArray.pushDouble(((Float) value).doubleValue());
336
338
  return typeArray;
337
339
  }
338
340
 
339
341
  if (value instanceof Long) {
340
- typeArray.pushInt(INT_NUMBER);
342
+ typeArray.pushInt(INT_DOUBLE);
341
343
  typeArray.pushDouble(((Long) value).doubleValue());
342
344
  return typeArray;
343
345
  }
@@ -461,14 +463,12 @@ public class ReactNativeFirebaseFirestoreSerialize {
461
463
  return true;
462
464
  case INT_BOOLEAN_FALSE:
463
465
  return false;
464
- case INT_NUMBER:
465
- // https://github.com/invertase/react-native-firebase/issues/3004
466
- // Number values come from JS as Strings on Android so we can check for floating points
467
- String numberStringValue = Objects.requireNonNull(typeArray.getString(1));
468
- if (numberStringValue.contains(".")) {
469
- return Double.valueOf(numberStringValue);
470
- }
471
- return Long.valueOf(numberStringValue, 10);
466
+ case INT_NEGATIVE_ZERO:
467
+ return -0.0;
468
+ case INT_INTEGER:
469
+ return (long) typeArray.getDouble(1);
470
+ case INT_DOUBLE:
471
+ return typeArray.getDouble(1);
472
472
  case INT_STRING:
473
473
  return typeArray.getString(1);
474
474
  case INT_STRING_EMPTY:
@@ -46,7 +46,7 @@ enum TYPE_MAP {
46
46
  INT_DOCUMENTID,
47
47
  INT_BOOLEAN_TRUE,
48
48
  INT_BOOLEAN_FALSE,
49
- INT_NUMBER,
49
+ INT_DOUBLE,
50
50
  INT_STRING,
51
51
  INT_STRING_EMPTY,
52
52
  INT_ARRAY,
@@ -56,6 +56,8 @@ enum TYPE_MAP {
56
56
  INT_BLOB,
57
57
  INT_FIELDVALUE,
58
58
  INT_OBJECT,
59
+ INT_INTEGER,
60
+ INT_NEGATIVE_ZERO,
59
61
  INT_UNKNOWN = -999,
60
62
  };
61
63
 
@@ -336,7 +338,7 @@ enum TYPE_MAP {
336
338
  }
337
339
 
338
340
  // Number
339
- typeArray[0] = @(INT_NUMBER);
341
+ typeArray[0] = @(INT_DOUBLE);
340
342
  typeArray[1] = value;
341
343
  return typeArray;
342
344
  }
@@ -400,7 +402,11 @@ enum TYPE_MAP {
400
402
  return @(YES);
401
403
  case INT_BOOLEAN_FALSE:
402
404
  return @(NO);
403
- case INT_NUMBER:
405
+ case INT_NEGATIVE_ZERO:
406
+ return @(-0.0);
407
+ case INT_INTEGER:
408
+ return @([typeMap[1] longLongValue]);
409
+ case INT_DOUBLE:
404
410
  return @([typeMap[1] doubleValue]);
405
411
  case INT_STRING:
406
412
  return typeMap[1];
@@ -16,7 +16,6 @@
16
16
  */
17
17
 
18
18
  import {
19
- isAndroid,
20
19
  isArray,
21
20
  isBoolean,
22
21
  isDate,
@@ -139,10 +138,15 @@ export function generateNativeData(value, ignoreUndefined) {
139
138
  }
140
139
 
141
140
  if (isNumber(value)) {
142
- if (isAndroid) {
143
- return getTypeMapInt('number', value.toString());
141
+ // mirror the JS SDK's integer detection algorithm
142
+ // https://github.com/firebase/firebase-js-sdk/blob/086df7c7e0299cedd9f3cff9080f46ca25cab7cd/packages/firestore/src/remote/number_serializer.ts#L56
143
+ if (value === 0 && 1 / value === -Infinity) {
144
+ return getTypeMapInt('negativeZero');
144
145
  }
145
- return getTypeMapInt('number', value);
146
+ if (Number.isSafeInteger(value)) {
147
+ return getTypeMapInt('integer', value);
148
+ }
149
+ return getTypeMapInt('double', value);
146
150
  }
147
151
 
148
152
  if (isString(value)) {
@@ -254,7 +258,9 @@ export function parseNativeData(firestore, nativeArray) {
254
258
  return true;
255
259
  case 'booleanFalse':
256
260
  return false;
257
- case 'number':
261
+ case 'double':
262
+ case 'integer':
263
+ case 'negativeZero':
258
264
  case 'string':
259
265
  return value;
260
266
  case 'stringEmpty':
@@ -25,7 +25,7 @@ const MAP = {
25
25
  documentid: 4, // to native only
26
26
  booleanTrue: 5,
27
27
  booleanFalse: 6,
28
- number: 7,
28
+ double: 7,
29
29
  string: 8,
30
30
  stringEmpty: 9,
31
31
  array: 10,
@@ -35,6 +35,8 @@ const MAP = {
35
35
  blob: 14,
36
36
  fieldvalue: 15,
37
37
  object: 16,
38
+ integer: 17,
39
+ negativeZero: 18,
38
40
  unknown: -999,
39
41
  };
40
42
 
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- module.exports = '13.1.1';
2
+ module.exports = '14.0.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/firestore",
3
- "version": "13.1.1",
3
+ "version": "14.0.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - Cloud Firestore is a NoSQL cloud database to store and sync data between your React Native application and Firebase's database. The API matches the Firebase Web SDK whilst taking advantage of the native SDKs performance and offline capabilities.",
6
6
  "main": "lib/index.js",
@@ -27,10 +27,10 @@
27
27
  "firestore"
28
28
  ],
29
29
  "peerDependencies": {
30
- "@react-native-firebase/app": "13.1.1"
30
+ "@react-native-firebase/app": "14.0.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "049886ae1dd36ca7b472238f649a6653ec2183f0"
35
+ "gitHead": "fcf375a763004967f94da70940d9f1aad591ef7a"
36
36
  }