mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Add serializer for value_or_null
This commit is contained in:
parent
ef01958b19
commit
8d05e4e05e
@ -52,6 +52,27 @@ namespace sqlpp
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template <typename Context, typename ValueType>
|
||||
struct serializer_t<Context, value_or_null_t<ValueType>>
|
||||
{
|
||||
using _serialize_check = consistent_t;
|
||||
using Operand = value_or_null_t<ValueType>;
|
||||
|
||||
static Context& _(const Operand& t, Context& context)
|
||||
{
|
||||
if (t._is_null)
|
||||
{
|
||||
context << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
serialize(wrap_operand_t<typename ValueType::_cpp_value_type>{t._value}, context);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
auto value_or_null(T t) -> value_or_null_t<value_type_of<wrap_operand_t<T>>>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user