From c9bea8b317720d2ab56d4c5ab7331a0d340ca3a7 Mon Sep 17 00:00:00 2001 From: ruben Date: Sat, 9 Nov 2019 13:05:15 +0000 Subject: [PATCH] Now YEAR has its own type in mysql::value Added tests for deserialize_text_value YEAR --- include/mysql/impl/deserialize_row_impl.hpp | 12 +++++++++++- include/mysql/value.hpp | 2 ++ test/deserialize_row.cpp | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/mysql/impl/deserialize_row_impl.hpp b/include/mysql/impl/deserialize_row_impl.hpp index b1e1c2ae..1072bb67 100644 --- a/include/mysql/impl/deserialize_row_impl.hpp +++ b/include/mysql/impl/deserialize_row_impl.hpp @@ -119,6 +119,15 @@ Error deserialize_text_value_impl(std::string_view from, std::nullptr_t& to) return Error::ok; } +Error deserialize_text_value_impl(std::string_view from, year& to) +{ + int value; + auto err = deserialize_text_value_impl(from, value); + if (err != Error::ok) return err; + to = year(value); + return to.ok() ? Error::ok : Error::protocol_value_error; +} + template Error deserialize_text_value_to_variant(std::string_view from, value& to, Args&&... args) { @@ -160,7 +169,6 @@ inline mysql::Error mysql::detail::deserialize_text_value( case field_type::short_: case field_type::int24: case field_type::long_: - case field_type::year: return meta.is_unsigned() ? deserialize_text_value_to_variant(from, output) : deserialize_text_value_to_variant(from, output); @@ -181,6 +189,8 @@ inline mysql::Error mysql::detail::deserialize_text_value( return deserialize_text_value_to_variant(from, output); case field_type::time: return deserialize_text_value_to_variant