Skip to content

Commit c73e30e

Browse files
---
yaml --- r: 9679 b: refs/heads/mrschmidt-timestamps c: b7cee60 h: refs/heads/master i: 9677: f5fe1fc 9675: 1b02326 9671: 4fa14aa 9663: 665a4bd
1 parent c06835d commit c73e30e

6 files changed

Lines changed: 22 additions & 28 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ refs/heads/michaelawyu-patch-1: 244423736b94700c9bc54fc63ec4f5dda65fb625
9999
refs/tags/0.47.0: 2e8688416bcae6150c0fa59936103554dbbe3821
100100
refs/heads/mrschmidt-core-timestamps: 19c1eca95467e588c21378cae2b136d14973d532
101101
refs/heads/mrschmidt-options: b94ffeeaf7f7e3083ca20fae1f7e7211544117f9
102-
refs/heads/mrschmidt-timestamps: b2ae7809f1110286181e8c8e5264bd4fff29fd4f
102+
refs/heads/mrschmidt-timestamps: b7cee6079af53a886c72742e85978d8a38f83d62

branches/mrschmidt-timestamps/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CustomClassMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import java.util.logging.Logger;
4848

4949
/** Helper class to convert to/from custom POJO classes and plain Java types. */
50-
public class CustomClassMapper {
50+
class CustomClassMapper {
5151
private static final Logger LOGGER = Logger.getLogger(CustomClassMapper.class.getName());
5252

5353
/** Maximum depth before we give up and assume it's a recursive object graph. */

branches/mrschmidt-timestamps/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public class DocumentSnapshot {
4949
private final FirestoreImpl firestore;
5050
private final DocumentReference docRef;
5151
@Nullable private final Map<String, Value> fields;
52-
@Nullable private Timestamp readTime;
53-
@Nullable private Timestamp updateTime;
54-
@Nullable private Timestamp createTime;
52+
@Nullable private final Timestamp readTime;
53+
@Nullable private final Timestamp updateTime;
54+
@Nullable private final Timestamp createTime;
5555

5656
DocumentSnapshot(
5757
FirestoreImpl firestore,

branches/mrschmidt-timestamps/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Precondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public final class Precondition {
2626
/** An empty Precondition that adds no enforcements */
2727
public static final Precondition NONE = new Precondition(null, null);
2828

29-
private Boolean exists;
30-
private Timestamp updateTime;
29+
private final Boolean exists;
30+
private final Timestamp updateTime;
3131

3232
private Precondition(Boolean exists, Timestamp updateTime) {
3333
this.exists = exists;

branches/mrschmidt-timestamps/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,15 +699,15 @@ public boolean equals(Object o) {
699699
.setTimestampValue(
700700
com.google.protobuf.Timestamp.newBuilder()
701701
.setSeconds(479978400)
702-
.setNanos(123000000))
702+
.setNanos(123000000)) // Dates only support millisecond precision.
703703
.build())
704704
.put(
705705
"timestampValue",
706706
Value.newBuilder()
707707
.setTimestampValue(
708708
com.google.protobuf.Timestamp.newBuilder()
709709
.setSeconds(479978400)
710-
.setNanos(123000))
710+
.setNanos(123000)) // Timestamps supports microsecond precision.
711711
.build())
712712
.put(
713713
"arrayValue",

branches/mrschmidt-timestamps/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ public void serverTimestamp() throws Exception {
200200
assertTrue(documentSnapshot.getDate("time").getTime() > 0);
201201
}
202202

203+
@Test
204+
public void updateMicrosecondTimestamp() throws Exception {
205+
DocumentReference documentReference = addDocument("time", Timestamp.ofTimeSecondsAndNanos(0, 123000));
206+
DocumentSnapshot documentSnapshot = documentReference.get().get();
207+
208+
Timestamp timestamp = documentSnapshot.getTimestamp("time");
209+
documentReference.update("time", timestamp);
210+
211+
documentSnapshot = documentReference.get().get();
212+
timestamp = documentSnapshot.getTimestamp("time");
213+
assertEquals(123000, timestamp.getNanos());
214+
}
215+
203216
@Test
204217
public void fieldDelete() throws Exception {
205218
Map<String, Object> fields = new HashMap<>();
@@ -245,25 +258,6 @@ public void defaultQuery() throws Exception {
245258
assertEquals("bar", documents.next().get("foo"));
246259
}
247260

248-
@Test
249-
public void queryForServerTimestamps() throws Exception {
250-
DocumentReference documentReference = addDocument("serverTime", FieldValue.serverTimestamp());
251-
DocumentSnapshot documentSnapshot = documentReference.get().get();
252-
Timestamp serverTime = documentSnapshot.getTimestamp("serverTime");
253-
254-
if (TimeUnit.NANOSECONDS.toMicros(serverTime.getNanos()) > 0) {
255-
// If serverTime has a microsecond component, this query produces no results as `getDate()`
256-
// truncates to milliseconds.
257-
Query query = randomColl.whereEqualTo("foo", documentSnapshot.getDate("serverTime"));
258-
QuerySnapshot querySnapshot = query.get().get();
259-
assertEquals(0, querySnapshot.size());
260-
}
261-
262-
Query query = randomColl.whereEqualTo("serverTime", serverTime);
263-
QuerySnapshot querySnapshot = query.get().get();
264-
assertEquals(1, querySnapshot.size());
265-
}
266-
267261
@Test
268262
public void noResults() throws Exception {
269263
QuerySnapshot querySnapshot = randomColl.get().get();

0 commit comments

Comments
 (0)