@@ -464,6 +464,39 @@ class FirebaseFirestoreTest {
464
464
assertNotEquals(DoubleAsTimestampSerializer .serverTimestamp, pendingWritesSnapshot.data(DoubleTimestamp .serializer(), ServerTimestampBehavior .ESTIMATE ).time)
465
465
}
466
466
467
+ @Test
468
+ fun testQueryByTimestamp () = runTest {
469
+ @Serializable
470
+ data class DocumentWithTimestamp (
471
+ val time : Timestamp
472
+ )
473
+
474
+ val collection = Firebase .firestore
475
+ .collection(" testQueryByTimestamp" )
476
+
477
+ val timestamp = Timestamp .now()
478
+
479
+ val pastTimestamp = Timestamp (timestamp.seconds - 60 , timestamp.nanoseconds)
480
+ val futureTimestamp = Timestamp (timestamp.seconds + 60 , timestamp.nanoseconds)
481
+
482
+ collection.add(DocumentWithTimestamp (pastTimestamp))
483
+ collection.add(DocumentWithTimestamp (futureTimestamp))
484
+
485
+ val equalityQueryResult = collection.where(
486
+ path = FieldPath (DocumentWithTimestamp ::time.name),
487
+ equalTo = pastTimestamp
488
+ ).get().documents.map { it.data<DocumentWithTimestamp >() }
489
+
490
+ assertEquals(listOf (DocumentWithTimestamp (pastTimestamp)), equalityQueryResult)
491
+
492
+ val gtQueryResult = collection.where(
493
+ path = FieldPath (DocumentWithTimestamp ::time.name),
494
+ greaterThan = timestamp
495
+ ).get().documents.map { it.data<DocumentWithTimestamp >() }
496
+
497
+ assertEquals(listOf (DocumentWithTimestamp (futureTimestamp)), gtQueryResult)
498
+ }
499
+
467
500
private suspend fun setupFirestoreData () {
468
501
Firebase .firestore.collection(" testFirestoreQuerying" )
469
502
.document(" one" )
0 commit comments