add array support for db query parameters

This commit is contained in:
jie 2021-08-10 13:58:56 +08:00
parent 0eb0478487
commit b6700ccc0b
1 changed files with 17 additions and 0 deletions

View File

@ -188,6 +188,23 @@ public:
} }
}; };
template <typename Type>
class db_value<std::vector<Type>> : public db_parameter {
private:
std::vector<Type> value_;
public:
db_value(const std::vector<Type>& value)
: value_{value} {}
std::string get_value(raw_db_transaction_type& tx) {
std::string res;
for (const auto& elem : value_) {
if (res.size() != 0) res += ", ";
res += db_value<Type>{elem}.get_value(tx);
}
return "ARRAY[" + res + "]";
}
};
namespace db_internal { namespace db_internal {
template <typename Param> template <typename Param>