From 4f99894cd4a2c34814f9fd6ac5e07ddde964b6e1 Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Tue, 7 Sep 2021 10:14:35 +0200 Subject: [PATCH] Backported value_t --- include/sqlpp11/value.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/value.h b/include/sqlpp11/value.h index b2b0a24b..72adb24b 100644 --- a/include/sqlpp11/value.h +++ b/include/sqlpp11/value.h @@ -32,12 +32,38 @@ namespace sqlpp { template - auto value(T t) -> wrap_operand_t + struct value_t : public wrap_operand_t, public expression_operators, value_type_of>> + { + using _base_t = wrap_operand_t; + using _base_t::_base_t; + + const _base_t& get_base() const + { + return *this; + } + }; + + template + auto value(T t) -> value_t { static_assert(is_wrapped_value_t>::value, "value() is to be called with non-sql-type like int, or string"); return {t}; } + + template + struct serializer_t> + { + using _serialize_check = consistent_t; + using Operand = value_t; + + static Context& _(const Operand& t, Context& context) + { + serialize(t.get_base(), context); + return context; + } + }; + } // namespace sqlpp #endif