Skip to content

Commit f45e747

Browse files
pragatimodincooke3andrewheardpaulb777guidev
authored
sync with master (#11132)
* [Infra] Avoid subshells in test script (#11094) * [Auth] Remove unreachable code (#11091) * [Auth] Remove unreachable code * Rename '-[FIRAuthStoredUserManager getStoredUserAccessGroupWithError:]' * Favor 'NULL' over 'nil' for a ** * Rename '-[FIRAuthStoredUserManager setStoredUserAccessGroup:error:]' * [Tooling] Add FIR_CLANG_FORMAT_PATH env var to style.sh (#11097) Added an environment variable to specify the path to the version of clang-format used by the style.sh script. * Carthage json updates for 10.8.0 (#11103) * Update versions for Release 10.9.0 (#11112) * [RemoteConfig] Expose NSUnderlyingError to client (#11102) * [Release Tooling] Separate out dynamic content from zip README.md (#11113) * Updated README Badges (#11117) * [Release] Enable macCatalyst support for Firestore targets (#11121) * [Release] Update Package.swift for 10.8.1 release * Update changelog entry for 10.8.1 Package.swift * New Cache Config API (#11057) * Fix bundle query resume bug (#11018) * Fix bundle query resume bug * fix * Update for proposed g3 ocmock changes (#11116) --------- Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com> Co-authored-by: Andrew Heard <andrewheard@google.com> Co-authored-by: Paul Beusterien <paulbeusterien@google.com> Co-authored-by: Guglielmo Faglioni <guglielmo@gorillatech.io> Co-authored-by: Max Cobb <5754073+maxxfrazer@users.noreply.github.com> Co-authored-by: wu-hui <53845758+wu-hui@users.noreply.github.com>
1 parent af8cc46 commit f45e747

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

FirebaseMessaging/Tests/UnitTests/FIRMessagingRemoteNotificationsProxyTest.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ - (void)testListeningForDelegateChangesOnInvalidUserNotificationCenter {
300300

301301
[(id<UNUserNotificationCenterDelegate>)invalidNotificationCenter.delegate
302302
userNotificationCenter:self.mockUserNotificationCenter
303-
willPresentNotification:OCMClassMock([UNNotification class])
303+
willPresentNotification:[UNNotification alloc]
304304
withCompletionHandler:^(UNNotificationPresentationOptions options){
305305
}];
306306
}
@@ -315,7 +315,7 @@ - (void)testSwizzlingInvalidUserNotificationCenterDelegate {
315315
OCMReject([self.mockMessaging appDidReceiveMessage:[OCMArg any]]);
316316

317317
[invalidDelegate userNotificationCenter:self.mockUserNotificationCenter
318-
willPresentNotification:OCMClassMock([UNNotification class])
318+
willPresentNotification:[UNNotification alloc]
319319
withCompletionHandler:^(UNNotificationPresentationOptions options){
320320
}];
321321
}

Firestore/core/src/bundle/bundle_serializer.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ using core::FieldFilter;
5353
using core::Filter;
5454
using core::LimitType;
5555
using core::OrderBy;
56+
using core::Query;
5657
using core::Target;
5758
using model::DeepClone;
5859
using model::Document;
@@ -376,10 +377,19 @@ BundledQuery BundleSerializer::DecodeBundledQuery(
376377
int32_t limit = DecodeLimit(reader, structured_query);
377378
LimitType limit_type = DecodeLimitType(reader, query);
378379

379-
return BundledQuery(Target(std::move(parent), std::move(collection_group),
380-
std::move(filters), std::move(order_bys), limit,
381-
std::move(start_at), std::move(end_at)),
382-
limit_type);
380+
if (!reader.ok()) {
381+
return {};
382+
}
383+
384+
return BundledQuery(
385+
Query(std::move(parent), std::move(collection_group), std::move(filters),
386+
std::move(order_bys), limit,
387+
// Not using `limit_type` because bundled queries are what the
388+
// backend sees, and there is no limit_to_last for the backend.
389+
// Limit type is applied when the query is read back instead.
390+
LimitType::None, std::move(start_at), std::move(end_at))
391+
.ToTarget(),
392+
limit_type);
383393
}
384394

385395
ResourcePath BundleSerializer::DecodeName(JsonReader& reader,

Firestore/core/src/core/target.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ class Target {
192192
}
193193
friend class Query;
194194
friend class remote::Serializer;
195-
friend class bundle::BundleSerializer;
196195
friend class local::LevelDbIndexManager;
197196

198197
/** Returns the field filters that target the given field path. */

Firestore/core/test/unit/bundle/bundle_serializer_test.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,38 @@ TEST_F(BundleSerializerTest, DecodeInvalidBundledDocumentMetadataFails) {
11611161
}
11621162
}
11631163

1164+
TEST_F(BundleSerializerTest, DecodeTargetWithoutImplicitOrderByOnName) {
1165+
std::string json(
1166+
R"({"name":"myNamedQuery",
1167+
"bundledQuery":{"parent":"projects/p/databases/default/documents",
1168+
"structuredQuery":{"from":[{"collectionId":"foo"}],
1169+
"limit":{"value":10}},"limitType":"FIRST"},
1170+
"readTime":{"seconds":"1679674432","nanos":579934000}})");
1171+
JsonReader reader;
1172+
auto named_query = bundle_serializer.DecodeNamedQuery(reader, Parse(json));
1173+
EXPECT_OK(reader.status());
1174+
EXPECT_EQ(testutil::Query("foo").WithLimitToFirst(10).ToTarget(),
1175+
named_query.bundled_query().target());
1176+
EXPECT_EQ(core::LimitType::First, named_query.bundled_query().limit_type());
1177+
}
1178+
1179+
TEST_F(BundleSerializerTest,
1180+
DecodeLimitToLastTargetWithoutImplicitOrderByOnName) {
1181+
std::string json(
1182+
R"({"name":"myNamedQuery",
1183+
"bundledQuery":{"parent":"projects/p/databases/default/documents",
1184+
"structuredQuery":{"from":[{"collectionId":"foo"}],
1185+
"limit":{"value":10}},"limitType":"LAST"},
1186+
"readTime":{"seconds":"1679674432","nanos":579934000}})");
1187+
JsonReader reader;
1188+
auto named_query = bundle_serializer.DecodeNamedQuery(reader, Parse(json));
1189+
EXPECT_OK(reader.status());
1190+
// Note `WithLimitToFirst(10)` is expected.
1191+
EXPECT_EQ(testutil::Query("foo").WithLimitToFirst(10).ToTarget(),
1192+
named_query.bundled_query().target());
1193+
EXPECT_EQ(core::LimitType::Last, named_query.bundled_query().limit_type());
1194+
}
1195+
11641196
} // namespace
11651197
} // namespace bundle
11661198
} // namespace firestore

0 commit comments

Comments
 (0)