@@ -201,7 +201,7 @@ public void serverTimestamp() throws Exception {
201201 }
202202
203203 @ Test
204- public void updateMicrosecondTimestamp () throws Exception {
204+ public void timestampDoesntGetTruncatedDuringUpdate () throws Exception {
205205 DocumentReference documentReference = addDocument ("time" , Timestamp .ofTimeSecondsAndNanos (0 , 123000 ));
206206 DocumentSnapshot documentSnapshot = documentReference .get ().get ();
207207
@@ -265,6 +265,23 @@ public void noResults() throws Exception {
265265 assertNotNull (querySnapshot .getReadTime ());
266266 }
267267
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+
268285 @ Test
269286 public void nestedQuery () throws Exception {
270287 randomColl = randomColl .document ("foo" ).collection ("bar" );
0 commit comments