Skip to content

Commit a26c34c

Browse files
Rename document_name to document_key (#3383)
1 parent 88ea99b commit a26c34c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ private SortedSet<IndexEntry> computeIndexEntries(Document document, FieldIndex
322322

323323
private void addIndexEntry(Document document, IndexEntry indexEntry) {
324324
db.execute(
325-
"INSERT INTO index_entries (index_id, uid, array_value, directional_value, document_name) "
325+
"INSERT INTO index_entries (index_id, uid, array_value, directional_value, document_key) "
326326
+ "VALUES(?, ?, ?, ?, ?)",
327327
indexEntry.getIndexId(),
328328
uid,
@@ -334,7 +334,7 @@ private void addIndexEntry(Document document, IndexEntry indexEntry) {
334334
private void deleteIndexEntry(Document document, IndexEntry indexEntry) {
335335
db.execute(
336336
"DELETE FROM index_entries WHERE index_id = ? AND uid = ? AND array_value = ? "
337-
+ "AND directional_value = ? AND document_name = ?",
337+
+ "AND directional_value = ? AND document_key = ?",
338338
indexEntry.getIndexId(),
339339
uid,
340340
indexEntry.getArrayValue(),
@@ -347,7 +347,7 @@ private SortedSet<IndexEntry> getExistingIndexEntries(
347347
SortedSet<IndexEntry> results = new TreeSet<>();
348348
db.query(
349349
"SELECT array_value, directional_value FROM index_entries "
350-
+ "WHERE index_id = ? AND document_name = ? AND uid = ?")
350+
+ "WHERE index_id = ? AND document_key = ? AND uid = ?")
351351
.binding(fieldIndex.getIndexId(), documentKey.toString(), uid)
352352
.forEach(
353353
row ->
@@ -424,7 +424,7 @@ private SQLitePersistence.Query generateQuery(
424424
// Build the statement. We always include the lower bound, and optionally include an array value
425425
// and an upper bound.
426426
StringBuilder statement = new StringBuilder();
427-
statement.append("SELECT document_name, directional_value FROM index_entries ");
427+
statement.append("SELECT document_key, directional_value FROM index_entries ");
428428
statement.append("WHERE index_id = ? AND uid = ? ");
429429
if (arrayValues != null) {
430430
statement.append("AND array_value = ? ");
@@ -439,14 +439,14 @@ private SQLitePersistence.Query generateQuery(
439439
// Create the UNION statement by repeating the above generated statement. We can then add
440440
// ordering and a limit clause.
441441
StringBuilder sql = repeatSequence(statement, statementCount, " UNION ");
442-
sql.append(" ORDER BY directional_value, document_name ");
442+
sql.append(" ORDER BY directional_value, document_key ");
443443
if (target.getLimit() != -1) {
444444
sql.append("LIMIT ").append(target.getLimit()).append(" ");
445445
}
446446

447447
if (notIn != null) {
448448
// Wrap the statement in a NOT-IN call.
449-
sql = new StringBuilder("SELECT document_name, directional_value FROM (").append(sql);
449+
sql = new StringBuilder("SELECT document_key, directional_value FROM (").append(sql);
450450
sql.append(") WHERE directional_value NOT IN (");
451451
sql.append(repeatSequence("?", notIn.length, ", "));
452452
sql.append(")");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ private void createFieldIndex() {
400400
+ "uid TEXT, "
401401
+ "array_value BLOB, " // index values for ArrayContains/ArrayContainsAny
402402
+ "directional_value BLOB, " // index values for equality and inequalities
403-
+ "document_name TEXT, "
404-
+ "PRIMARY KEY (index_id, uid, array_value, directional_value, document_name))");
403+
+ "document_key TEXT, "
404+
+ "PRIMARY KEY (index_id, uid, array_value, directional_value, document_key))");
405405

406406
db.execSQL(
407407
"CREATE INDEX read_time ON remote_documents(read_time_seconds, read_time_nanos)");

0 commit comments

Comments
 (0)