15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_SQL_STATEMENT_H 16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_SQL_STATEMENT_H 20 #include <google/spanner/v1/spanner.pb.h> 22 #include <unordered_map> 35 using SqlStatementProto =
36 google::spanner::v1::ExecuteBatchDmlRequest::Statement;
37 SqlStatementProto ToProto(SqlStatement s);
58 using ParamType = std::unordered_map<std::string, Value>;
63 : statement_(std::move(statement)) {}
66 : statement_(std::move(statement)), params_(std::move(params)) {}
78 std::string
const&
sql()
const {
return statement_; }
89 std::vector<std::string> ParameterNames()
const;
96 google::cloud::StatusOr<Value> GetParameter(
97 std::string
const& parameter_name)
const;
100 return a.statement_ == b.statement_ && a.params_ == b.params_;
115 friend internal::SqlStatementProto internal::ToProto(
SqlStatement s);
117 std::string statement_;
126 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_SQL_STATEMENT_H friend bool operator==(SqlStatement const &a, SqlStatement const &b)
std::string const & sql() const
Returns the SQL statement.
SqlStatement(std::string statement, ParamType params)
Constructs a SqlStatement with specified parameters.
friend bool operator!=(SqlStatement const &a, SqlStatement const &b)
std::unordered_map< std::string, Value > ParamType
Type alias for parameter collection.
Contains all the Cloud Spanner C++ client types and functions.
SqlStatement(std::string statement)
Constructs a SqlStatement without parameters.
#define SPANNER_CLIENT_NS
ParamType const & params() const
Returns the collection of parameters.
std::ostream & operator<<(std::ostream &os, Backup const &bn)
Represents a potentially parameterized SQL statement.