Even moe function tests and a few corrections

This commit is contained in:
Roland Bock
2013-11-08 09:09:52 +01:00
parent 813549690e
commit 81c77a58f4
9 changed files with 73 additions and 17 deletions

View File

@@ -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

View File

@@ -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) };
}
};

View File

@@ -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) };
}

View File

@@ -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) };
}

View File

@@ -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) };
}

View File

@@ -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

View File

@@ -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) };
}

View File

@@ -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);