mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Added support for empty in() and not_in()
I wonder why SQL does not have that anyway.
This commit is contained in:
parent
34376bdd28
commit
2b8a36aa97
@ -95,6 +95,33 @@ namespace sqlpp
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
struct value_list_t;
|
||||
|
||||
template<typename Context, typename Operand, typename Container>
|
||||
struct serializer_t<Context, in_t<Operand, value_list_t<Container>>>
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, value_list_t<Container>>;
|
||||
using T = in_t<Operand, value_list_t<Container>>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
const auto& value_list = std::get<0>(t._args);
|
||||
if (value_list._container.empty())
|
||||
{
|
||||
context << " 'operand in empty list' = 'false' ";
|
||||
}
|
||||
else
|
||||
{
|
||||
serialize(t._operand, context);
|
||||
context << " IN(";
|
||||
serialize(value_list, context);
|
||||
context << ')';
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -95,6 +95,34 @@ namespace sqlpp
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
struct value_list_t;
|
||||
|
||||
template<typename Context, typename Operand, typename Container>
|
||||
struct serializer_t<Context, not_in_t<Operand, value_list_t<Container>>>
|
||||
{
|
||||
using _serialize_check = serialize_check_of<Context, value_list_t<Container>>;
|
||||
using T = not_in_t<Operand, value_list_t<Container>>;
|
||||
|
||||
static Context& _(const T& t, Context& context)
|
||||
{
|
||||
const auto& value_list = std::get<0>(t._args);
|
||||
if (value_list._container.empty())
|
||||
{
|
||||
context << " 'operand not in empty list' != 'false' ";
|
||||
}
|
||||
else
|
||||
{
|
||||
serialize(t._operand, context);
|
||||
context << " NOT IN(";
|
||||
serialize(value_list, context);
|
||||
context << ')';
|
||||
}
|
||||
return context;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user