0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Fixed handling of IS NULL and IS NOT NULL expressions

This commit is contained in:
Roland Bock 2013-08-21 19:32:11 +02:00
parent c41a181ca9
commit cf1dae396a
2 changed files with 35 additions and 3 deletions

View File

@ -127,12 +127,12 @@ namespace sqlpp
return { *static_cast<const Base*>(this), std::forward<T>(t) }; return { *static_cast<const Base*>(this), std::forward<T>(t) };
} }
nary_expression_t<Base, is_null_> is_null() const null_expression_t<Base, is_null_> is_null() const
{ {
return { *static_cast<const Base*>(this) }; return { *static_cast<const Base*>(this) };
} }
nary_expression_t<Base, is_not_null_> is_not_null() const null_expression_t<Base, is_not_null_> is_not_null() const
{ {
return { *static_cast<const Base*>(this) }; return { *static_cast<const Base*>(this) };
} }
@ -147,7 +147,7 @@ namespace sqlpp
return { *static_cast<const Base*>(this) }; return { *static_cast<const Base*>(this) };
} }
// Hint: use wrappers for containers... // Hint: use value_list wrapper for containers...
template<typename... T> template<typename... T>
nary_expression_t<Base, in_, typename Constraint<T>::type...> in(T&&... t) const nary_expression_t<Base, in_, typename Constraint<T>::type...> in(T&&... t) const
{ {

View File

@ -172,6 +172,38 @@ namespace sqlpp
Lhs _lhs; Lhs _lhs;
}; };
template<typename Lhs, typename O>
struct null_expression_t: public O::_value_type::template operators<null_expression_t<Lhs, O>>
{
using _value_type = typename O::_value_type;
null_expression_t(Lhs&& l):
_lhs(std::move(l))
{}
null_expression_t(const Lhs& l):
_lhs(l)
{}
null_expression_t(const null_expression_t&) = default;
null_expression_t(null_expression_t&&) = default;
null_expression_t& operator=(const null_expression_t&) = default;
null_expression_t& operator=(null_expression_t&&) = default;
~null_expression_t() = default;
template<typename Db>
void serialize(std::ostream& os, Db& db) const
{
os << "(";
_lhs.serialize(os, db);
os << ")";
os << O::_name;
}
private:
Lhs _lhs;
};
template<typename Lhs, typename O, typename... Rhs> template<typename Lhs, typename O, typename... Rhs>
struct nary_expression_t: public O::_value_type::template operators<nary_expression_t<Lhs, O, Rhs...>> struct nary_expression_t: public O::_value_type::template operators<nary_expression_t<Lhs, O, Rhs...>>
{ {