Skip to content

Commit 1a10046

Browse files
Fix test
1 parent 207c71b commit 1a10046

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/core/Bound.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ public String positionString() {
7676

7777
/** Returns true if a document sorts before a bound using the provided sort order. */
7878
public boolean sortsBeforeDocument(List<OrderBy> orderBy, Document document) {
79+
int comparison = compareToDocument(orderBy, document);
80+
return inclusive ? comparison <= 0 : comparison < 0;
81+
}
82+
83+
/** Returns true if a document sorts after a bound using the provided sort order. */
84+
public boolean sortsAfterDocument(List<OrderBy> orderBy, Document document) {
85+
int comparison = compareToDocument(orderBy, document);
86+
return inclusive ? comparison >= 0 : comparison > 0;
87+
}
88+
89+
private int compareToDocument(List<OrderBy> orderBy, Document document) {
7990
hardAssert(position.size() <= orderBy.size(), "Bound has more components than query's orderBy");
8091
int comparison = 0;
8192
for (int i = 0; i < position.size(); i++) {
@@ -103,8 +114,7 @@ public boolean sortsBeforeDocument(List<OrderBy> orderBy, Document document) {
103114
break;
104115
}
105116
}
106-
107-
return inclusive ? comparison <= 0 : comparison < 0;
117+
return comparison;
108118
}
109119

110120
@Override

firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ private boolean matchesBounds(Document doc) {
448448
if (startAt != null && !startAt.sortsBeforeDocument(getOrderBy(), doc)) {
449449
return false;
450450
}
451-
if (endAt != null && endAt.sortsBeforeDocument(getOrderBy(), doc)) {
451+
if (endAt != null && !endAt.sortsAfterDocument(getOrderBy(), doc)) {
452452
return false;
453453
}
454454
return true;

0 commit comments

Comments
 (0)