Skip to content

Commit 5bc0fef

Browse files
Remove shared index entries (#3138)
1 parent 0e612ea commit 5bc0fef

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ final class SQLiteIndexManager implements IndexManager {
6868

6969
private final SQLitePersistence db;
7070
private final LocalSerializer serializer;
71-
private final User user;
71+
private final String uid;
7272
private final Map<String, Map<Integer, FieldIndex>> memoizedIndexes;
7373

7474
private boolean started = false;
@@ -77,7 +77,7 @@ final class SQLiteIndexManager implements IndexManager {
7777
SQLiteIndexManager(SQLitePersistence persistence, LocalSerializer serializer, User user) {
7878
this.db = persistence;
7979
this.serializer = serializer;
80-
this.user = user;
80+
this.uid = user.isAuthenticated() ? user.getUid() : "";
8181
this.memoizedIndexes = new HashMap<>();
8282
}
8383

@@ -376,7 +376,7 @@ private void addSingleEntry(
376376
"INSERT INTO index_entries (index_id, uid, array_value, directional_value, document_name) "
377377
+ "VALUES(?, ?, ?, ?, ?)",
378378
indexId,
379-
document.hasLocalMutations() ? user.getUid() : null,
379+
uid,
380380
arrayValue,
381381
directionalValue,
382382
document.getKey().toString());
@@ -450,7 +450,7 @@ private SQLitePersistence.Query generateQuery(
450450
// and an upper bound.
451451
StringBuilder statement = new StringBuilder();
452452
statement.append("SELECT document_name, directional_value FROM index_entries ");
453-
statement.append("WHERE index_id = ? AND (uid IS NULL or uid = ?) ");
453+
statement.append("WHERE index_id = ? AND uid = ? ");
454454
if (arrayValues != null) {
455455
statement.append("AND array_value = ? ");
456456
}
@@ -504,7 +504,7 @@ private Object[] fillBounds(
504504
int offset = 0;
505505
for (int i = 0; i < statementCount; ++i) {
506506
bindArgs[offset++] = indexId;
507-
bindArgs[offset++] = user.getUid();
507+
bindArgs[offset++] = uid;
508508
if (arrayValues != null) {
509509
bindArgs[offset++] = encodeSingleElement(arrayValues.get(i / statementsPerArrayValue));
510510
}

0 commit comments

Comments
 (0)