aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/core
diff options
context:
space:
mode:
authorGravatar rsgowman <rgowman@google.com>2018-05-28 16:42:23 -0400
committerGravatar GitHub <noreply@github.com>2018-05-28 16:42:23 -0400
commite318923d318151e503de03be53aef1a0cffc58e3 (patch)
tree6c964ac148f92bd40178cc5c4d40ef0fed3f1d48 /Firestore/core
parent94132a7e00ff153e9b593e94a818a6db22545014 (diff)
"Handle" BatchGetDocumentsResponse.transaction (by ignoring it) (#1318)
Diffstat (limited to 'Firestore/core')
-rw-r--r--Firestore/core/src/firebase/firestore/remote/serializer.cc16
-rw-r--r--Firestore/core/test/firebase/firestore/remote/serializer_test.cc11
2 files changed, 15 insertions, 12 deletions
diff --git a/Firestore/core/src/firebase/firestore/remote/serializer.cc b/Firestore/core/src/firebase/firestore/remote/serializer.cc
index 6ea5844..e06dcb4 100644
--- a/Firestore/core/src/firebase/firestore/remote/serializer.cc
+++ b/Firestore/core/src/firebase/firestore/remote/serializer.cc
@@ -504,7 +504,7 @@ std::unique_ptr<MaybeDocument> Serializer::DecodeBatchGetDocumentsResponse(
// Initialize BatchGetDocumentsResponse fields to their default values
std::unique_ptr<MaybeDocument> found;
std::string missing;
- // TODO(rsgowman): transaction
+ // We explicitly ignore the 'transaction' field
SnapshotVersion read_time = SnapshotVersion::None();
while (reader->bytes_left()) {
@@ -515,6 +515,7 @@ std::unique_ptr<MaybeDocument> Serializer::DecodeBatchGetDocumentsResponse(
switch (tag.field_number) {
case google_firestore_v1beta1_BatchGetDocumentsResponse_found_tag:
case google_firestore_v1beta1_BatchGetDocumentsResponse_missing_tag:
+ case google_firestore_v1beta1_BatchGetDocumentsResponse_transaction_tag:
case google_firestore_v1beta1_BatchGetDocumentsResponse_read_time_tag:
if (tag.wire_type != PB_WT_STRING) {
reader->set_status(
@@ -524,10 +525,6 @@ std::unique_ptr<MaybeDocument> Serializer::DecodeBatchGetDocumentsResponse(
}
break;
- case google_firestore_v1beta1_BatchGetDocumentsResponse_transaction_tag:
- // TODO(rsgowman)
- abort();
-
default:
reader->set_status(Status(
FirestoreErrorCode::DataLoss,
@@ -559,8 +556,13 @@ std::unique_ptr<MaybeDocument> Serializer::DecodeBatchGetDocumentsResponse(
break;
case google_firestore_v1beta1_BatchGetDocumentsResponse_transaction_tag:
- // TODO(rsgowman)
- abort();
+ // This field is ignored by the client sdk, but we still need to extract
+ // it.
+ // TODO(rsgowman) switch this to reader->SkipField() (or whatever we end
+ // up calling it) once that exists. Possibly group this with other
+ // ignored and/or unknown fields
+ reader->ReadString();
+ break;
case google_firestore_v1beta1_BatchGetDocumentsResponse_read_time_tag:
read_time = SnapshotVersion{
diff --git a/Firestore/core/test/firebase/firestore/remote/serializer_test.cc b/Firestore/core/test/firebase/firestore/remote/serializer_test.cc
index ba9ea47..db13228 100644
--- a/Firestore/core/test/firebase/firestore/remote/serializer_test.cc
+++ b/Firestore/core/test/firebase/firestore/remote/serializer_test.cc
@@ -230,20 +230,21 @@ class SerializerTest : public ::testing::Test {
/**
* Creates entries in the proto that we don't care about.
*
- * We ignore create time in our serializer. We never set it, and never read it
- * (other than to throw it away). But the server could (and probably does) set
- * it, so we need to be able to discard it properly. The ExpectRoundTrip deals
- * with this asymmetry.
+ * We ignore certain fields in our serializer. We never set them, and never
+ * read them (other than to throw them away). But the server could (and
+ * probably does) set them, so we need to be able to discard them properly.
+ * The ExpectRoundTrip deals with this asymmetry.
*
* This method adds these ignored fields to the proto.
*/
void TouchIgnoredBatchGetDocumentsResponseFields(
v1beta1::BatchGetDocumentsResponse* proto) {
+ proto->set_transaction("random bytes");
+
// TODO(rsgowman): This method currently assumes that this is a 'found'
// document. We (probably) will need to adjust this to work with NoDocuments
// too.
v1beta1::Document* doc_proto = proto->mutable_found();
-
google::protobuf::Timestamp* create_time_proto =
doc_proto->mutable_create_time();
create_time_proto->set_seconds(8765);