mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-05 20:50:34 -06:00
Added function tests and fixed a few return types
This commit is contained in:
@@ -138,13 +138,13 @@ namespace sqlpp
|
||||
|
||||
// Hint: use value_list wrapper for containers...
|
||||
template<typename... T>
|
||||
in_t<true, Base, typename Constraint<T>::type...> in(T&&... t) const
|
||||
in_t<true, boolean, Base, typename Constraint<T>::type...> in(T&&... t) const
|
||||
{
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t)... };
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
in_t<false, Base, typename Constraint<T>::type...> not_in(T&&... t) const
|
||||
in_t<false, boolean, Base, typename Constraint<T>::type...> not_in(T&&... t) const
|
||||
{
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t)... };
|
||||
}
|
||||
|
||||
@@ -35,13 +35,14 @@ namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template<bool NotInverted, typename Operand, typename... Args>
|
||||
struct in_t: public Operand::_value_type::template operators<in_t<NotInverted, Operand, Args...>>
|
||||
// The ValueType should be boolean, this is a hack because boolean is not fully defined when the compiler first gets here...
|
||||
template<bool NotInverted, typename ValueType, typename Operand, typename... Args>
|
||||
struct in_t: public ValueType::_base_value_type::template operators<in_t<NotInverted, ValueType, Args...>>
|
||||
{
|
||||
static constexpr bool _inverted = not NotInverted;
|
||||
static_assert(sizeof...(Args) > 0, "in() requires at least one argument");
|
||||
|
||||
struct _value_type: public Operand::_value_type::_base_value_type
|
||||
struct _value_type: public ValueType::_base_value_type // we requite fully defined boolean here
|
||||
{
|
||||
using _is_named_expression = std::true_type;
|
||||
};
|
||||
|
||||
@@ -35,13 +35,14 @@ namespace sqlpp
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template<typename Operand, typename Pattern>
|
||||
struct like_t: public Operand::_value_type::template operators<like_t<Operand, Pattern>>
|
||||
// The ValueType should be boolean, this is a hack because boolean is not fully defined when the compiler first gets here...
|
||||
template<typename ValueType, typename Operand, typename Pattern>
|
||||
struct like_t: public ValueType::_base_value_type::template operators<like_t<ValueType, Operand, Pattern>>
|
||||
{
|
||||
static_assert(is_text_t<Operand>::value, "Operand for like() has to be a text");
|
||||
static_assert(is_text_t<Pattern>::value, "Pattern for like() has to be a text");
|
||||
|
||||
struct _value_type: public Operand::_value_type::_base_value_type
|
||||
struct _value_type: public ValueType::_base_value_type // we requite fully defined boolean here
|
||||
{
|
||||
using _is_named_expression = std::true_type;
|
||||
};
|
||||
@@ -87,12 +88,6 @@ namespace sqlpp
|
||||
Pattern _pattern;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
auto like(T&&... t) -> typename detail::like_t<typename operand_t<T, is_text_t>::type...>
|
||||
{
|
||||
return { std::forward<T>(t)... };
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SQLPP_MAX_H
|
||||
#define SQLPP_MAX_H
|
||||
#ifndef SQLPP_SUM_H
|
||||
#define SQLPP_SUM_H
|
||||
|
||||
#include <sstream>
|
||||
#include <sqlpp11/type_traits.h>
|
||||
@@ -35,7 +35,7 @@ namespace sqlpp
|
||||
namespace detail
|
||||
{
|
||||
template<typename Expr>
|
||||
struct max_t: public boolean::template operators<max_t<Expr>>
|
||||
struct sum_t: public boolean::template operators<sum_t<Expr>>
|
||||
{
|
||||
static_assert(is_numeric_t<Expr>::value, "sum() requires a numeric expression as argument");
|
||||
|
||||
@@ -50,23 +50,23 @@ namespace sqlpp
|
||||
template<typename T>
|
||||
struct _member_t
|
||||
{
|
||||
T max;
|
||||
T sum;
|
||||
};
|
||||
};
|
||||
|
||||
max_t(Expr&& expr):
|
||||
sum_t(Expr&& expr):
|
||||
_expr(std::move(expr))
|
||||
{}
|
||||
|
||||
max_t(const Expr& expr):
|
||||
sum_t(const Expr& expr):
|
||||
_expr(expr)
|
||||
{}
|
||||
|
||||
max_t(const max_t&) = default;
|
||||
max_t(max_t&&) = default;
|
||||
max_t& operator=(const max_t&) = default;
|
||||
max_t& operator=(max_t&&) = default;
|
||||
~max_t() = default;
|
||||
sum_t(const sum_t&) = default;
|
||||
sum_t(sum_t&&) = default;
|
||||
sum_t& operator=(const sum_t&) = default;
|
||||
sum_t& operator=(sum_t&&) = default;
|
||||
~sum_t() = default;
|
||||
|
||||
template<typename Db>
|
||||
void serialize(std::ostream& os, Db& db) const
|
||||
@@ -83,7 +83,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto max(T&& t) -> typename detail::max_t<typename operand_t<T, is_value_t>::type>
|
||||
auto sum(T&& t) -> typename detail::sum_t<typename operand_t<T, is_value_t>::type>
|
||||
{
|
||||
return { std::forward<T>(t) };
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace sqlpp
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
detail::like_t<Base, typename _constraint<T>::type> like(T&& t) const
|
||||
detail::like_t<boolean, Base, typename _constraint<T>::type> like(T&& t) const
|
||||
{
|
||||
return { *static_cast<const Base*>(this), std::forward<T>(t) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user