Fixed result types for signed OP unsigned expressions.

This commit is contained in:
rbock
2016-11-12 10:35:03 +01:00
parent 7f701dff90
commit 7c20a68e0b
5 changed files with 10 additions and 7 deletions

View File

@@ -53,7 +53,7 @@ namespace sqlpp
struct return_type_plus<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
{
using check = consistent_t;
using type = integral;
using type = plus_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
};
template <typename L, typename R>
@@ -67,7 +67,7 @@ namespace sqlpp
struct return_type_minus<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
{
using check = consistent_t;
using type = integral;
using type = minus_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
};
template <typename L, typename R>
@@ -81,7 +81,7 @@ namespace sqlpp
struct return_type_multiplies<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
{
using check = consistent_t;
using type = integral;
using type = multiplies_t<wrap_operand_t<L>, integral, wrap_operand_t<R>>;
};
template <typename L, typename R>
@@ -95,7 +95,7 @@ namespace sqlpp
struct return_type_divides<L, R, binary_operand_check_t<L, is_integral_t, R, is_unsigned_integral_t>>
{
using check = consistent_t;
using type = integral;
using type = divides_t<wrap_operand_t<L>, wrap_operand_t<R>>;
};
template <typename L, typename R>

View File

@@ -38,7 +38,7 @@
namespace sqlpp
{
struct integral;
template <typename Expression>
struct expression_operators<Expression, unsigned_integral> : public basic_expression_operators<Expression>
{

View File

@@ -39,8 +39,10 @@ int As(int, char* [])
compare(__LINE__, foo.omega.as(cheese), "tab_foo.omega AS cheese");
compare(__LINE__, (foo.omega + 17).as(cheese), "(tab_foo.omega+17) AS cheese");
compare(__LINE__, (foo.omega - 17).as(cheese), "(tab_foo.omega-17) AS cheese");
compare(__LINE__, (foo.omega - uint32_t(17)).as(cheese), "(tab_foo.omega-17) AS cheese");
compare(__LINE__, (foo.omega - bar.alpha).as(cheese), "(tab_foo.omega-tab_bar.alpha) AS cheese");
compare(__LINE__, (count(foo.omega) - bar.alpha).as(cheese), "(COUNT(tab_foo.omega)-tab_bar.alpha) AS cheese");
compare(__LINE__, (count(foo.omega) - uint32_t(17)).as(cheese), "(COUNT(tab_foo.omega)-17) AS cheese");
return 0;
}

View File

@@ -28,8 +28,8 @@ set(test_serializer_names
From
In
Insert
Where
TableAlias
Where
)
create_test_sourcelist(test_serializer_sources test_serializer_main.cpp ${test_serializer_names})

View File

@@ -167,7 +167,8 @@ int SelectType(int, char* [])
static_assert(sqlpp::is_integral_t<sqlpp::return_type_minus_t<sqlpp::integral, T>>::value, "type requirement");
static_assert(sqlpp::is_integral_t<sqlpp::return_type_plus_t<sqlpp::integral, T>>::value, "type requirement");
static_assert(sqlpp::is_integral_t<sqlpp::return_type_multiplies_t<sqlpp::integral, T>>::value, "type requirement");
static_assert(sqlpp::is_integral_t<sqlpp::return_type_divides_t<sqlpp::integral, T>>::value, "type requirement");
static_assert(sqlpp::is_floating_point_t<sqlpp::return_type_divides_t<sqlpp::integral, T>>::value,
"type requirement");
static_assert(sqlpp::is_integral_t<sqlpp::return_type_modulus_t<sqlpp::integral, T>>::value, "type requirement");
}