Skip to content

Commit 18e5947

Browse files
authored
impl(bigtable): populate Value proto with Type for parameters (#15752)
1 parent 465ce17 commit 18e5947

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

google/cloud/bigtable/bound_query.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ google::bigtable::v2::ExecuteQueryRequest BoundQuery::ToRequestProto() const {
3535

3636
google::protobuf::Map<std::string, google::bigtable::v2::Value> parameters;
3737
for (auto const& kv : parameters_) {
38-
parameters[kv.first] =
39-
bigtable_internal::ValueInternals::ToProto(kv.second).second;
38+
auto type_value = bigtable_internal::ValueInternals::ToProto(kv.second);
39+
google::bigtable::v2::Value v = std::move(type_value.second);
40+
*v.mutable_type() = std::move(type_value.first);
41+
parameters[kv.first] = std::move(v);
4042
}
41-
*result.mutable_params() = parameters;
43+
*result.mutable_params() = std::move(parameters);
4244
return result;
4345
}
4446

google/cloud/bigtable/bound_query_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ TEST(BoundQuery, ToRequestProto) {
9797
auto val1 = proto.params().find("val1")->second;
9898
EXPECT_TRUE(val1.has_bool_value());
9999
EXPECT_EQ(true, val1.bool_value());
100+
EXPECT_TRUE(val1.type().has_bool_type());
100101

101102
// The second parameter is a double.
102103
EXPECT_TRUE(proto.params().contains("val2"));
103104
auto val2 = proto.params().find("val2")->second;
104105
EXPECT_TRUE(val2.has_float_value());
105106
EXPECT_EQ(2.0, val2.float_value());
107+
EXPECT_TRUE(val2.type().has_float64_type());
106108

107109
// Cancel all pending operations, satisfying any remaining futures.
108110
fake_cq_impl->SimulateCompletion(false);

0 commit comments

Comments
 (0)