File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
main/java/com/google/firebase/firestore/bundle
test/java/com/google/firebase/firestore/bundle Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 1
- # Unreleased (22.1.0)
1
+ # Unreleased (22.1.1)
2
+ - [ fixed] Fixed an issue that dropped the limit for queries loaded from
3
+ Bundles that were generated by the NodeJS SDK.
4
+
5
+ # 22.10
2
6
- [ feature] Added support for Firestore Bundles via
3
7
` FirebaseFirestore.loadBundle() ` and ` FirebaseFirestore.getNamedQuery() ` .
4
8
Bundles contain pre-packaged data produced with the NodeJS Server SDK and
Original file line number Diff line number Diff line change @@ -162,7 +162,12 @@ private BundledQuery decodeBundledQuery(JSONObject bundledQuery) throws JSONExce
162
162
163
163
private int decodeLimit (JSONObject structuredQuery ) {
164
164
JSONObject limit = structuredQuery .optJSONObject ("limit" );
165
- return limit != null ? limit .optInt ("value" , -1 ) : -1 ;
165
+
166
+ if (limit != null ) {
167
+ return limit .optInt ("value" , -1 ); // ProtobufJS
168
+ } else {
169
+ return structuredQuery .optInt ("limit" , -1 ); // Proto3 JSON
170
+ }
166
171
}
167
172
168
173
private Bound decodeBound (@ Nullable JSONObject bound ) throws JSONException {
Original file line number Diff line number Diff line change @@ -553,9 +553,16 @@ public void testDecodeOrderByQuery() throws JSONException {
553
553
554
554
@ Test
555
555
public void testDecodesLimitQuery () throws JSONException {
556
- String json = "{ from: [ { collectionId: 'coll' } ], limit: { value: 5 } }" ;
557
- Query query = TestUtil .query ("coll" ).limitToFirst (5 );
558
- assertDecodesNamedQuery (json , query );
556
+ String [] json =
557
+ new String [] {
558
+ "{ from: [ { collectionId: 'coll' } ], limit: { value: 5 } }" , // ProtobufJS
559
+ "{ from: [ { collectionId: 'coll' } ], limit: 5 }" // Proto3 JSON
560
+ };
561
+
562
+ for (String encoded : json ) {
563
+ Query query = TestUtil .query ("coll" ).limitToFirst (5 );
564
+ assertDecodesNamedQuery (encoded , query );
565
+ }
559
566
}
560
567
561
568
@ Test
You can’t perform that action at this time.
0 commit comments