Skip to content

Commit bbb2895

Browse files
authored
fix(database, android): improve type handling for startAt query modifier and add test for numeric startAt (#17880)
1 parent 44d99a9 commit bbb2895

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/firebase_database/firebase_database/android/src/main/kotlin/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,7 @@ class FirebaseDatabasePlugin :
883883
val value = modifier["value"]
884884
query = when (value) {
885885
is String -> query.startAt(value)
886-
is Double -> query.startAt(value)
887-
is Int -> query.startAt(value.toDouble())
886+
is Number -> query.startAt(value.toDouble())
888887
is Boolean -> query.startAt(value)
889888
else -> query.startAt(value.toString())
890889
}

tests/integration_test/firebase_database/query_e2e.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ void setupQueryTests() {
3131
expect(snapshot.value, isNull);
3232
});
3333

34+
test(
35+
'streams respect orderByChild with numeric startAt',
36+
() async {
37+
await ref.set({
38+
't1': {'timestamp': 1, 'value': 'old'},
39+
't2': {'timestamp': 1000, 'value': 'current'},
40+
});
41+
42+
final events = await ref
43+
.orderByChild('timestamp')
44+
.startAt(1000)
45+
.onChildAdded
46+
.take(1)
47+
.toList();
48+
49+
expect(events.single.snapshot.key, 't2');
50+
expect(events.single.snapshot.child('value').value, 'current');
51+
},
52+
);
53+
3454
test('starts at the correct value', () async {
3555
await ref.set({
3656
'a': 1,

0 commit comments

Comments
 (0)