From f81dab3fe23f661a1b511e559be15a2b6ab8f384 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Wed, 26 Nov 2025 14:04:59 +0000 Subject: [PATCH] fix(database, android): improve type handling for startAt query modifier and add test for numeric startAt --- .../database/FirebaseDatabasePlugin.kt | 3 +-- .../firebase_database/query_e2e.dart | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/firebase_database/firebase_database/android/src/main/kotlin/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.kt b/packages/firebase_database/firebase_database/android/src/main/kotlin/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.kt index dfc2b328b4f5..3cf18f64a429 100644 --- a/packages/firebase_database/firebase_database/android/src/main/kotlin/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.kt +++ b/packages/firebase_database/firebase_database/android/src/main/kotlin/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.kt @@ -883,8 +883,7 @@ class FirebaseDatabasePlugin : val value = modifier["value"] query = when (value) { is String -> query.startAt(value) - is Double -> query.startAt(value) - is Int -> query.startAt(value.toDouble()) + is Number -> query.startAt(value.toDouble()) is Boolean -> query.startAt(value) else -> query.startAt(value.toString()) } diff --git a/tests/integration_test/firebase_database/query_e2e.dart b/tests/integration_test/firebase_database/query_e2e.dart index 23b0c1536757..aec3d570a4f6 100644 --- a/tests/integration_test/firebase_database/query_e2e.dart +++ b/tests/integration_test/firebase_database/query_e2e.dart @@ -31,6 +31,26 @@ void setupQueryTests() { expect(snapshot.value, isNull); }); + test( + 'streams respect orderByChild with numeric startAt', + () async { + await ref.set({ + 't1': {'timestamp': 1, 'value': 'old'}, + 't2': {'timestamp': 1000, 'value': 'current'}, + }); + + final events = await ref + .orderByChild('timestamp') + .startAt(1000) + .onChildAdded + .take(1) + .toList(); + + expect(events.single.snapshot.key, 't2'); + expect(events.single.snapshot.child('value').value, 'current'); + }, + ); + test('starts at the correct value', () async { await ref.set({ 'a': 1,