Skip to content

Commit ea59b3d

Browse files
committed
Fix
1 parent c954002 commit ea59b3d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/bundle/BundleSerializer.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,18 @@ private BundledQuery decodeBundledQuery(JSONObject bundledQuery) throws JSONExce
153153
Query.LimitType limitType = decodeLimitType(bundledQuery);
154154

155155
return new BundledQuery(
156-
new Query(parent, collectionGroup, filters, orderBys, limit, limitType, startAt, endAt)
156+
new Query(
157+
parent,
158+
collectionGroup,
159+
filters,
160+
orderBys,
161+
limit,
162+
// Not using `limitType` because bundled queries are what the backend sees,
163+
// and there is no limit_to_last for the backend.
164+
// Limit type is applied when the query is read back instead.
165+
Query.LimitType.LIMIT_TO_FIRST,
166+
startAt,
167+
endAt)
157168
.toTarget(),
158169
limitType);
159170
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ public void testDecodesLimitToLastTargetWithoutImplicitOrderByOnName() throws JS
696696
+ "\"readTime\":{\"seconds\":\"1679674432\",\"nanos\":579934000}}";
697697
NamedQuery query = serializer.decodeNamedQuery(new JSONObject(json));
698698
assertEquals(
699-
TestUtil.query("foo").limitToLast(10).toTarget(), query.getBundledQuery().getTarget());
699+
// Note that `limitToFirst(10)` is expected.
700+
TestUtil.query("foo").limitToFirst(10).toTarget(), query.getBundledQuery().getTarget());
700701
assertEquals(Query.LimitType.LIMIT_TO_LAST, query.getBundledQuery().getLimitType());
701702
}
702703

0 commit comments

Comments
 (0)