From 8d05e4e05eed319c8e61baf3d0c48defe7786e93 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 28 Jun 2018 19:20:09 +0200 Subject: [PATCH] Add serializer for value_or_null --- include/sqlpp11/value_or_null.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/sqlpp11/value_or_null.h b/include/sqlpp11/value_or_null.h index 0643d5ad..788f1899 100644 --- a/include/sqlpp11/value_or_null.h +++ b/include/sqlpp11/value_or_null.h @@ -52,6 +52,27 @@ namespace sqlpp bool _is_null; }; + template + struct serializer_t> + { + using _serialize_check = consistent_t; + using Operand = value_or_null_t; + + static Context& _(const Operand& t, Context& context) + { + if (t._is_null) + { + context << "NULL"; + } + else + { + serialize(wrap_operand_t{t._value}, context); + } + + return context; + } + }; + template auto value_or_null(T t) -> value_or_null_t>> {