Skip to content

Commit 3e89c25

Browse files
Comments
1 parent 1a10046 commit 3e89c25

File tree

6 files changed

+33
-20
lines changed

6 files changed

+33
-20
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public List<Value> getPosition() {
5656
return position;
5757
}
5858

59+
/**
60+
* Whether the bound includes the documents that lie directly on the bound. Returns {@code true}
61+
* for {@code startAt()} and {@code endAt()} and false for {@code startAfter()} and {@code
62+
* endBefore()}.
63+
*/
5964
public boolean isInclusive() {
6065
return inclusive;
6166
}

firebase-firestore/src/test/java/com/google/firebase/firestore/bundle/BundleSerializerTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ public void testDecodesStartAtQuery() throws JSONException {
579579
+ "from: [ { collectionId: 'coll' } ],\n"
580580
+ "orderBy: [ { field: { fieldPath: 'foo' } } ],\n"
581581
+ "startAt: { values: [ { stringValue: 'bar' } ], before: true } }";
582-
Query query = TestUtil.query("coll").orderBy(orderBy("foo")).startAt(bound(true, "bar"));
582+
Query query =
583+
TestUtil.query("coll").orderBy(orderBy("foo")).startAt(bound(/* inclusive= */ true, "bar"));
583584
assertDecodesNamedQuery(json, query);
584585
}
585586

@@ -590,7 +591,8 @@ public void testDecodesEndBeforeQuery() throws JSONException {
590591
+ "from: [ { collectionId: 'coll' } ],\n"
591592
+ "orderBy: [ { field: { fieldPath: 'foo' } } ],\n"
592593
+ "endAt: { values: [ { stringValue: 'bar' } ], before: true } }";
593-
Query query = TestUtil.query("coll").orderBy(orderBy("foo")).endAt(bound(false, "bar"));
594+
Query query =
595+
TestUtil.query("coll").orderBy(orderBy("foo")).endAt(bound(/* inclusive= */ false, "bar"));
594596
assertDecodesNamedQuery(json, query);
595597
}
596598

firebase-firestore/src/test/java/com/google/firebase/firestore/core/QueryTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,14 @@ public void testCanonicalIdsAreStable() {
673673
"collection|f:aarray_containsa|ob:__name__asc");
674674
assertCanonicalId(baseQuery.orderBy(orderBy("a")), "collection|f:|ob:aasc__name__asc");
675675
assertCanonicalId(
676-
baseQuery.orderBy(orderBy("a")).startAt(bound(true, "foo", Arrays.asList(1, 2, 3))),
676+
baseQuery
677+
.orderBy(orderBy("a"))
678+
.startAt(bound(/* inclusive= */ true, "foo", Arrays.asList(1, 2, 3))),
677679
"collection|f:|ob:aasc__name__asc|lb:b:foo,[1,2,3]");
678680
assertCanonicalId(
679-
baseQuery.orderBy(orderBy("a")).endAt(bound(true, "foo", Arrays.asList(1, 2, 3))),
681+
baseQuery
682+
.orderBy(orderBy("a"))
683+
.endAt(bound(/* inclusive= */ true, "foo", Arrays.asList(1, 2, 3))),
680684
"collection|f:|ob:aasc__name__asc|ub:a:foo,[1,2,3]");
681685
assertCanonicalId(baseQuery.limitToFirst(5), "collection|f:|ob:__name__asc|l:5");
682686
assertCanonicalId(baseQuery.limitToLast(5), "collection|f:|ob:__name__desc|l:5");

firebase-firestore/src/test/java/com/google/firebase/firestore/core/TargetTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ public void filterWithOrderByQueryBound() {
156156

157157
@Test
158158
public void startAtQueryBound() {
159-
Target target = query("c").orderBy(orderBy("foo")).startAt(bound(true, "bar")).toTarget();
159+
Target target =
160+
query("c").orderBy(orderBy("foo")).startAt(bound(/* inclusive= */ true, "bar")).toTarget();
160161
FieldIndex index =
161162
new FieldIndex("c").withAddedField(field("foo"), FieldIndex.Segment.Kind.ORDERED);
162163

@@ -176,7 +177,7 @@ public void startAtWithFilterQueryBound() {
176177
.filter(filter("b", "==", "b1"))
177178
.orderBy(orderBy("a"))
178179
.orderBy(orderBy("b"))
179-
.startAt(bound(true, "a1", "b1"))
180+
.startAt(bound(/* inclusive= */ true, "a1", "b1"))
180181
.toTarget();
181182
FieldIndex index =
182183
new FieldIndex("c")
@@ -198,7 +199,7 @@ public void startAfterWithFilterQueryBound() {
198199
.filter(filter("b", "==", "b1"))
199200
.orderBy(orderBy("a"))
200201
.orderBy(orderBy("b"))
201-
.startAt(bound(false, "a2", "b1"))
202+
.startAt(bound(/* inclusive= */ false, "a2", "b1"))
202203
.toTarget();
203204
FieldIndex index =
204205
new FieldIndex("c")
@@ -220,7 +221,7 @@ public void startAfterDoesNotChangeBoundIfNotApplicable() {
220221
.filter(filter("b", "==", "b2"))
221222
.orderBy(orderBy("a"))
222223
.orderBy(orderBy("b"))
223-
.startAt(bound(false, "a1", "b1"))
224+
.startAt(bound(/* inclusive= */ false, "a1", "b1"))
224225
.toTarget();
225226
FieldIndex index =
226227
new FieldIndex("c")
@@ -236,7 +237,8 @@ public void startAfterDoesNotChangeBoundIfNotApplicable() {
236237

237238
@Test
238239
public void endAtQueryBound() {
239-
Target target = query("c").orderBy(orderBy("foo")).endAt(bound(true, "bar")).toTarget();
240+
Target target =
241+
query("c").orderBy(orderBy("foo")).endAt(bound(/* inclusive= */ true, "bar")).toTarget();
240242
FieldIndex index =
241243
new FieldIndex("c").withAddedField(field("foo"), FieldIndex.Segment.Kind.CONTAINS);
242244

@@ -256,7 +258,7 @@ public void endAtWithFilterQueryBound() {
256258
.filter(filter("b", "==", "b2"))
257259
.orderBy(orderBy("a"))
258260
.orderBy(orderBy("b"))
259-
.endAt(bound(true, "a1", "b1"))
261+
.endAt(bound(/* inclusive= */ true, "a1", "b1"))
260262
.toTarget();
261263
FieldIndex index =
262264
new FieldIndex("c")
@@ -278,7 +280,7 @@ public void endBeforeWithFilterQueryBound() {
278280
.filter(filter("b", "==", "b2"))
279281
.orderBy(orderBy("a"))
280282
.orderBy(orderBy("b"))
281-
.endAt(bound(false, "a1", "b1"))
283+
.endAt(bound(/* inclusive= */ false, "a1", "b1"))
282284
.toTarget();
283285
FieldIndex index =
284286
new FieldIndex("c")
@@ -300,7 +302,7 @@ public void endBeforeDoesNotChangeBoundIfNotApplicable() {
300302
.filter(filter("b", "==", "b1"))
301303
.orderBy(orderBy("a"))
302304
.orderBy(orderBy("b"))
303-
.endAt(bound(false, "a2", "b2"))
305+
.endAt(bound(/* inclusive= */ false, "a2", "b2"))
304306
.toTarget();
305307
FieldIndex index =
306308
new FieldIndex("c")

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteIndexManagerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,28 +149,28 @@ public void testRangeFilter() {
149149
@Test
150150
public void testStartAtFilter() {
151151
setUpSingleValueFilter();
152-
Query query = query("coll").orderBy(orderBy("count")).startAt(bound(true, 2));
152+
Query query = query("coll").orderBy(orderBy("count")).startAt(bound(/* inclusive= */ true, 2));
153153
verifyResults(query, "coll/doc2", "coll/doc3");
154154
}
155155

156156
@Test
157157
public void testStartAfterFilter() {
158158
setUpSingleValueFilter();
159-
Query query = query("coll").orderBy(orderBy("count")).startAt(bound(false, 2));
159+
Query query = query("coll").orderBy(orderBy("count")).startAt(bound(/* inclusive= */ false, 2));
160160
verifyResults(query, "coll/doc3");
161161
}
162162

163163
@Test
164164
public void testEndAtFilter() {
165165
setUpSingleValueFilter();
166-
Query query = query("coll").orderBy(orderBy("count")).endAt(bound(true, 2));
166+
Query query = query("coll").orderBy(orderBy("count")).endAt(bound(/* inclusive= */ true, 2));
167167
verifyResults(query, "coll/doc1", "coll/doc2");
168168
}
169169

170170
@Test
171171
public void testEndBeforeFilter() {
172172
setUpSingleValueFilter();
173-
Query query = query("coll").orderBy(orderBy("count")).endAt(bound(false, 2));
173+
Query query = query("coll").orderBy(orderBy("count")).endAt(bound(/* inclusive= */ false, 2));
174174
verifyResults(query, "coll/doc1");
175175
}
176176

@@ -182,8 +182,8 @@ public void testRangeWithBoundFilter() {
182182
.filter(filter("count", ">=", 1))
183183
.filter(filter("count", "<=", 3))
184184
.orderBy(orderBy("count"))
185-
.startAt(bound(false, 1))
186-
.endAt(bound(true, 2));
185+
.startAt(bound(/* inclusive= */ false, 1))
186+
.endAt(bound(/* inclusive= */ true, 2));
187187
verifyResults(startAt, "coll/doc2");
188188
}
189189

firebase-firestore/src/test/java/com/google/firebase/firestore/remote/RemoteSerializerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,8 @@ public void testEncodesLimits() {
977977
public void testEncodesBounds() {
978978
Query q =
979979
Query.atPath(ResourcePath.fromString("docs"))
980-
.startAt(bound(true, refValue(databaseId, key("foo/bar"))))
981-
.endAt(bound(true, refValue(databaseId, key("foo/baz"))));
980+
.startAt(bound(/* inclusive= */ true, refValue(databaseId, key("foo/bar"))))
981+
.endAt(bound(/* inclusive= */ true, refValue(databaseId, key("foo/baz"))));
982982
Target actual = serializer.encodeTarget(wrapTargetData(q));
983983

984984
StructuredQuery.Builder structuredQueryBuilder =

0 commit comments

Comments
 (0)