@@ -201,7 +201,7 @@ public void serverTimestamp() throws Exception {
201
201
}
202
202
203
203
@ Test
204
- public void updateMicrosecondTimestamp () throws Exception {
204
+ public void timestampDoesntGetTruncatedDuringUpdate () throws Exception {
205
205
DocumentReference documentReference = addDocument ("time" , Timestamp .ofTimeSecondsAndNanos (0 , 123000 ));
206
206
DocumentSnapshot documentSnapshot = documentReference .get ().get ();
207
207
@@ -265,6 +265,23 @@ public void noResults() throws Exception {
265
265
assertNotNull (querySnapshot .getReadTime ());
266
266
}
267
267
268
+ @ Test
269
+ public void queryWithMicrosecondPrecision () throws Exception {
270
+ Timestamp microsecondTimestamp = Timestamp .ofTimeSecondsAndNanos (0 , 123000 );
271
+
272
+ DocumentReference documentReference = addDocument ("time" , microsecondTimestamp );
273
+ DocumentSnapshot documentSnapshot = documentReference .get ().get ();
274
+
275
+ Query query = randomColl .whereEqualTo ("time" , microsecondTimestamp );
276
+ QuerySnapshot querySnapshot = query .get ().get ();
277
+ assertEquals (1 , querySnapshot .size ());
278
+
279
+ // Using `.toDate()` truncates to millseconds, and hence the query doesn't match.
280
+ query = randomColl .whereEqualTo ("time" , microsecondTimestamp .toDate ());
281
+ querySnapshot = query .get ().get ();
282
+ assertEquals (0 , querySnapshot .size ());
283
+ }
284
+
268
285
@ Test
269
286
public void nestedQuery () throws Exception {
270
287
randomColl = randomColl .document ("foo" ).collection ("bar" );
0 commit comments