Skip to content

Temporarily remove NamedQuery from the public API #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions firestore/integration_test_internal/src/bundle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,6 @@ class BundleTest : public FirestoreIntegrationTest {
MapFieldValue{{"k", FieldValue::String("b")},
{"bar", FieldValue::Integer(2)}}));
}

{
Query limit = AwaitResult(db->NamedQuery(kLimitQueryName));
auto limit_snapshot = AwaitResult(limit.Get(Source::kCache));
EXPECT_THAT(
QuerySnapshotToValues(limit_snapshot),
testing::ElementsAre(MapFieldValue{{"k", FieldValue::String("b")},
{"bar", FieldValue::Integer(2)}}));
}

{
Query limit_to_last = AwaitResult(db->NamedQuery(kLimitToLastQueryName));
auto limit_to_last_snapshot =
AwaitResult(limit_to_last.Get(Source::kCache));
EXPECT_THAT(
QuerySnapshotToValues(limit_to_last_snapshot),
testing::ElementsAre(MapFieldValue{{"k", FieldValue::String("a")},
{"bar", FieldValue::Integer(1)}}));
}
}
};

Expand Down Expand Up @@ -259,21 +240,6 @@ TEST_F(BundleTest, LoadBundleWithDocumentsAlreadyPulledFromBackend) {
testing::ElementsAre(
MapFieldValue{{"bar", FieldValue::String("newValueA")}},
MapFieldValue{{"bar", FieldValue::String("newValueB")}}));

{
Query limit = AwaitResult(db->NamedQuery(kLimitQueryName));
EXPECT_THAT(QuerySnapshotToValues(AwaitResult(limit.Get(Source::kCache))),
testing::ElementsAre(
MapFieldValue{{"bar", FieldValue::String("newValueB")}}));
}

{
Query limit_to_last = AwaitResult(db->NamedQuery(kLimitToLastQueryName));
EXPECT_THAT(
QuerySnapshotToValues(AwaitResult(limit_to_last.Get(Source::kCache))),
testing::ElementsAre(
MapFieldValue{{"bar", FieldValue::String("newValueA")}}));
}
}

TEST_F(BundleTest, LoadedDocumentsShouldNotBeGarbageCollectedRightAway) {
Expand Down Expand Up @@ -316,28 +282,6 @@ TEST_F(BundleTest, LoadDocumentsFromOtherProjectsShouldFail) {
VerifyErrorProgress(progresses[1]);
}

TEST_F(BundleTest, GetInvalidNamedQuery) {
Firestore* db = TestFirestore();
{
auto future = db->NamedQuery("DOES_NOT_EXIST");
Await(future);
EXPECT_EQ(future.status(), FutureStatus::kFutureStatusComplete);
EXPECT_EQ(future.error(), Error::kErrorNotFound);
}
{
auto future = db->NamedQuery("");
Await(future);
EXPECT_EQ(future.status(), FutureStatus::kFutureStatusComplete);
EXPECT_EQ(future.error(), Error::kErrorNotFound);
}
{
auto future = db->NamedQuery("\xc3\x28");
Await(future);
EXPECT_EQ(future.status(), FutureStatus::kFutureStatusComplete);
EXPECT_EQ(future.error(), Error::kErrorNotFound);
}
}

} // namespace
} // namespace firestore
} // namespace firebase
5 changes: 0 additions & 5 deletions firestore/src/common/firestore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,5 @@ Future<LoadBundleTaskProgress> Firestore::LoadBundle(
return internal_->LoadBundle(bundle, std::move(progress_callback));
}

Future<Query> Firestore::NamedQuery(const std::string& query_name) {
if (!internal_) return FailedFuture<Query>();
return internal_->NamedQuery(query_name);
}

} // namespace firestore
} // namespace firebase
15 changes: 0 additions & 15 deletions firestore/src/include/firebase/firestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,6 @@ class Firestore {
const std::string& bundle,
std::function<void(const LoadBundleTaskProgress&)> progress_callback);

/**
* Reads a Firestore `Query` from the local cache, identified by the given
* name.
*
* Named queries are packaged into bundles on the server side (along with the
* resulting documents) and loaded into local cache using `LoadBundle`. Once
* in the local cache, you can use this method to extract a query by name.
*
* If a query cannot be found, the returned future will complete with its
* `error()` set to a non-zero error code.
*
* @param query_name The name of the query to read from saved bundles.
*/
virtual Future<Query> NamedQuery(const std::string& query_name);

protected:
/**
* Default constructor, to be used only for mocking `Firestore`.
Expand Down
17 changes: 0 additions & 17 deletions firestore/src/main/firestore_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,22 +378,5 @@ Future<LoadBundleTaskProgress> FirestoreInternal::LoadBundle(
return promise.future();
}

Future<Query> FirestoreInternal::NamedQuery(const std::string& query_name) {
auto promise = promise_factory_.CreatePromise<Query>(AsyncApi::kNamedQuery);
firestore_core_->GetNamedQuery(
query_name,
[this, promise](const absl::optional<core::Query>& query) mutable {
if (query.has_value()) {
promise.SetValue(
MakePublic(api::Query(query.value(), firestore_core_)));
} else {
promise.SetError(
Status(Error::kErrorNotFound, "Named query cannot be found"));
}
});

return promise.future();
}

} // namespace firestore
} // namespace firebase
1 change: 0 additions & 1 deletion firestore/src/main/firestore_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class FirestoreInternal {
Future<LoadBundleTaskProgress> LoadBundle(
const std::string& bundle,
std::function<void(const LoadBundleTaskProgress&)> progress_callback);
Future<Query> NamedQuery(const std::string& query_name);

// Manages the ListenerRegistrationInternal objects.
void RegisterListenerRegistration(ListenerRegistrationInternal* registration);
Expand Down