progress on in conditions with queries and enums
This commit is contained in:
@@ -52,38 +52,32 @@ static const matador::utils::enum_mapper<Color> color_enum({
|
||||
{Color::Brown, "brown"}
|
||||
});
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
template<>
|
||||
struct data_type_traits<Color, void>
|
||||
struct matador::sql::data_type_traits<Color, void>
|
||||
{
|
||||
inline static data_type_t builtin_type(std::size_t size)
|
||||
{ return data_type_traits<std::string>::builtin_type(size); }
|
||||
inline static data_type_t builtin_type(std::size_t size)
|
||||
{ return data_type_traits<std::string>::builtin_type(size); }
|
||||
|
||||
static void read_value(query_result_reader &reader, const char *id, size_t index, Color &value)
|
||||
{
|
||||
std::string enum_string;
|
||||
reader.read_value(id, index, enum_string, 64);
|
||||
auto enum_opt = color_enum.to_enum(enum_string);
|
||||
if (enum_opt) {
|
||||
value = enum_opt.value();
|
||||
static void read_value(query_result_reader &reader, const char *id, size_t index, Color &value)
|
||||
{
|
||||
std::string enum_string;
|
||||
reader.read_value(id, index, enum_string, 64);
|
||||
if (const auto enum_opt = color_enum.to_enum(enum_string)) {
|
||||
value = enum_opt.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static any_type create_value(Color &value)
|
||||
{
|
||||
return color_enum.to_string(value);
|
||||
}
|
||||
static any_type create_value(const Color &value)
|
||||
{
|
||||
return color_enum.to_string(value);
|
||||
}
|
||||
|
||||
static void bind_value(parameter_binder &binder, size_t index, Color &value)
|
||||
{
|
||||
binder.bind(index, color_enum.to_string(value));
|
||||
}
|
||||
static void bind_value(parameter_binder &binder, size_t index, Color &value)
|
||||
{
|
||||
binder.bind(index, color_enum.to_string(value));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE_METHOD(TypeTraitsTestFixture, "Special handling of attributes with type traits", "[typetraits]")
|
||||
{
|
||||
schema.attach<location>("location");
|
||||
|
||||
Reference in New Issue
Block a user