From de34cc2dcb76c2bd195b7d4297fe267fabc8abfe Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Thu, 7 Nov 2024 11:19:35 +0000 Subject: [PATCH] fix(android): allow null value for average --- .../ReactNativeFirebaseFirestoreCollectionModule.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/firestore/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java b/packages/firestore/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java index ce368b0e7d..113e5e16b8 100644 --- a/packages/firestore/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java +++ b/packages/firestore/android/src/reactnative/java/io/invertase/firebase/firestore/ReactNativeFirebaseFirestoreCollectionModule.java @@ -271,9 +271,12 @@ public void aggregateQuery( break; case "average": Number average = snapshot.get(average(Objects.requireNonNull(field))); - result.putDouble( - Objects.requireNonNull(key), - Objects.requireNonNull(average).doubleValue()); + String averageKey = Objects.requireNonNull(key); + if (average == null) { + result.putNull(averageKey); + } else { + result.putDouble(averageKey, Objects.requireNonNull(average).doubleValue()); + } break; default: throw new Error("Invalid AggregateType: " + aggType);