Skip to content

Commit 6b9b25d

Browse files
Use update_time_seconds/update_time_nanos
1 parent 4c3c5b2 commit 6b9b25d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/local/SQLiteRemoteDocumentCache.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.firebase.firestore.model.DocumentKey;
2626
import com.google.firebase.firestore.model.MaybeDocument;
2727
import com.google.firebase.firestore.model.ResourcePath;
28+
import com.google.firebase.firestore.model.SnapshotVersion;
2829
import com.google.firebase.firestore.util.BackgroundQueue;
2930
import com.google.firebase.firestore.util.Executors;
3031
import com.google.protobuf.InvalidProtocolBufferException;
@@ -142,6 +143,7 @@ public ImmutableSortedMap<DocumentKey, Document> getAllDocumentsMatchingQuery(
142143

143144
String prefixPath = EncodedPath.encode(prefix);
144145
String prefixSuccessorPath = EncodedPath.prefixSuccessor(prefixPath);
146+
Timestamp updateTime = sinceUpdateTime.getTimestamp();
145147

146148
BackgroundQueue backgroundQueue = new BackgroundQueue();
147149

@@ -152,8 +154,14 @@ public ImmutableSortedMap<DocumentKey, Document> getAllDocumentsMatchingQuery(
152154
int rowsProcessed =
153155
db.query(
154156
"SELECT path, contents FROM remote_documents WHERE path >= ? AND path < ? "
155-
+ "AND (snapshot_version_micros > ? OR snapshot_version_micros IS NULL)")
156-
.binding(prefixPath, prefixSuccessorPath, sinceUpdateTime.toMicroseconds())
157+
+ "AND (update_time_seconds IS NULL OR update_time_seconds > ? "
158+
+ "OR (update_time_seconds = ? AND update_time_nanos > ?))")
159+
.binding(
160+
prefixPath,
161+
prefixSuccessorPath,
162+
updateTime.getSeconds(),
163+
updateTime.getSeconds(),
164+
updateTime.getNanoseconds())
157165
.forEach(
158166
row -> {
159167
// TODO: Actually implement a single-collection query

0 commit comments

Comments
 (0)