mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-01 18:51:15 -06:00
Even moe function tests and a few corrections
This commit is contained in:
@@ -42,7 +42,7 @@ namespace sqlpp
|
||||
|
||||
struct _value_type: public Select::_value_type::_base_value_type
|
||||
{
|
||||
using _is_nameless_expression = std::true_type; // must not be named
|
||||
using _is_multi_expression = std::true_type; // must not be named
|
||||
};
|
||||
|
||||
struct _name_t
|
||||
|
||||
@@ -126,17 +126,20 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
binary_expression_t<Base, and_, typename _constraint<T>::type> operator and(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, or_, typename _constraint<T>::type> operator or(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
not_t<Base> operator not() const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be as operand for operator not");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,13 +65,6 @@ namespace sqlpp
|
||||
static constexpr const char* _name = ">";
|
||||
};
|
||||
|
||||
struct is_not_null_
|
||||
{
|
||||
using _value_type = boolean;
|
||||
static constexpr const char* _name = "IS NOT NULL";
|
||||
};
|
||||
|
||||
|
||||
// basic operators
|
||||
template<typename Base, template<typename> class Constraint>
|
||||
struct basic_operators
|
||||
@@ -79,55 +72,65 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
equal_t<Base, typename Constraint<T>::type> operator==(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
not_equal_t<Base, typename Constraint<T>::type> operator!=(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
template<typename T>
|
||||
binary_expression_t<Base, lt_, typename Constraint<T>::type> operator<(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, le_, typename Constraint<T>::type> operator<=(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, ge_, typename Constraint<T>::type> operator>=(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, gt_, typename Constraint<T>::type> operator>(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
is_null_t<true, boolean, Base> is_null() const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used with is_null()");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
is_null_t<false, boolean, Base> is_not_null() const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used with is_not_null()");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
sort_order_t<Base, sort_type::asc> asc()
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used for sorting");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
sort_order_t<Base, sort_type::desc> desc()
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used for sorting");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
@@ -135,19 +138,21 @@ namespace sqlpp
|
||||
template<typename... T>
|
||||
in_t<true, boolean, Base, typename Constraint<T>::type...> in(T&&... t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used with in()");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t)... };
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
in_t<false, boolean, Base, typename Constraint<T>::type...> not_in(T&&... t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot with be used with not_in()");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t)... };
|
||||
}
|
||||
|
||||
template<typename alias_provider>
|
||||
expression_alias_t<Base, typename std::decay<alias_provider>::type> as(alias_provider&&)
|
||||
{
|
||||
static_assert(not is_nameless_expression_t<Base>::value, "expression cannot have a name, e.g. like any()");
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot have a name");
|
||||
return { *static_cast<const Base*>(this) };
|
||||
}
|
||||
|
||||
|
||||
@@ -128,24 +128,28 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
binary_expression_t<Base, plus_, typename _constraint<T>::type> operator +(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, minus_, typename _constraint<T>::type> operator -(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, multiplies_, typename _constraint<T>::type> operator *(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, divides_, typename _constraint<T>::type> operator /(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
|
||||
@@ -131,24 +131,28 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
binary_expression_t<Base, plus_<T>, typename _constraint<T>::type> operator +(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, minus_<T>, typename _constraint<T>::type> operator -(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, multiplies_<T>, typename _constraint<T>::type> operator *(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
binary_expression_t<Base, divides_, typename _constraint<T>::type> operator /(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace sqlpp
|
||||
|
||||
struct _value_type: public Select::_value_type::_base_value_type
|
||||
{
|
||||
using _is_nameless_expression = std::true_type; // must not be named
|
||||
using _is_multi_expression = std::true_type; // must not be named
|
||||
};
|
||||
|
||||
struct _name_t
|
||||
|
||||
@@ -106,12 +106,14 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
detail::concat_t<Base, typename _constraint<T>::type> operator+(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
detail::like_t<boolean, Base, typename _constraint<T>::type> like(T&& t) const
|
||||
{
|
||||
static_assert(not is_multi_expression_t<Base>::value, "multi-expression cannot be used as left hand side operand");
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace sqlpp
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(value);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(expression);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(named_expression);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(nameless_expression);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(multi_expression);
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(alias); // FIXME: Is this really part of the value?
|
||||
SQLPP_IS_VALUE_TRAIT_GENERATOR(select_flag);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user