mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
See what MSVC says in case of an invalid conversion
This commit is contained in:
parent
0a77c73e1d
commit
cda1249b69
@ -33,6 +33,7 @@
|
|||||||
#include <sqlpp11/result_field.h>
|
#include <sqlpp11/result_field.h>
|
||||||
#include <sqlpp11/exception.h>
|
#include <sqlpp11/exception.h>
|
||||||
#include <sqlpp11/type_traits.h>
|
#include <sqlpp11/type_traits.h>
|
||||||
|
#include <sqlpp11/bad_statement.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
@ -115,7 +116,9 @@ namespace sqlpp
|
|||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator _cpp_value_type() const
|
operator typename std::conditional<_null_is_trivial or (not _can_be_null::value),
|
||||||
|
_cpp_value_type,
|
||||||
|
bad_statement>::type() const
|
||||||
{
|
{
|
||||||
return value();
|
return value();
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ function(test_constraint name pattern)
|
|||||||
set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern})
|
set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${pattern})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
add_executable(see_what_happens no_conversion_operator_if_null_not_trivial.cpp)
|
||||||
|
target_link_libraries(see_what_happens PRIVATE sqlpp11 sqlpp11_testing)
|
||||||
test_constraint(count_of_count "count\\(\\) cannot be used on an aggregate function")
|
test_constraint(count_of_count "count\\(\\) cannot be used on an aggregate function")
|
||||||
test_constraint(max_of_max "max\\(\\) cannot be used on an aggregate function")
|
test_constraint(max_of_max "max\\(\\) cannot be used on an aggregate function")
|
||||||
test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha")
|
test_constraint(no_conversion_operator_if_null_not_trivial "int i = row.alpha")
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
SQLPP_ALIAS_PROVIDER(kaesekuchen)
|
SQLPP_ALIAS_PROVIDER(kaesekuchen)
|
||||||
|
|
||||||
int Function(int, char*[])
|
int Function(int, char* [])
|
||||||
{
|
{
|
||||||
MockDb db = {};
|
MockDb db = {};
|
||||||
const auto f = test::TabFoo{};
|
const auto f = test::TabFoo{};
|
||||||
@ -286,7 +286,7 @@ int Function(int, char*[])
|
|||||||
static_assert(sqlpp::is_integral_t<TT>::value, "type requirement");
|
static_assert(sqlpp::is_integral_t<TT>::value, "type requirement");
|
||||||
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
static_assert(not sqlpp::is_floating_point_t<TT>::value, "type requirement");
|
||||||
|
|
||||||
if (false and db(select(count(t.alpha)).from(t).where(true)).front().count)
|
if (false and db(select(count(t.alpha)).from(t).where(true)).front().count > 0)
|
||||||
{ /* do something */
|
{ /* do something */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,11 +446,14 @@ int Function(int, char*[])
|
|||||||
|
|
||||||
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
for (const auto& row : db(select(all_of(t)).from(t).where(true)))
|
||||||
{
|
{
|
||||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.alpha)), sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.alpha)>::type>>::value,
|
static_assert(std::is_same<decltype(sqlpp::tvin(row.alpha)),
|
||||||
|
sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.alpha)>::type>>::value,
|
||||||
"result fields are accepted and not wrapped");
|
"result fields are accepted and not wrapped");
|
||||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.beta)), sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.beta)>::type>>::value,
|
static_assert(std::is_same<decltype(sqlpp::tvin(row.beta)),
|
||||||
|
sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.beta)>::type>>::value,
|
||||||
"result fields are accepted and not wrapped");
|
"result fields are accepted and not wrapped");
|
||||||
static_assert(std::is_same<decltype(sqlpp::tvin(row.gamma)), sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.gamma)>::type>>::value,
|
static_assert(std::is_same<decltype(sqlpp::tvin(row.gamma)),
|
||||||
|
sqlpp::tvin_arg_t<typename std::remove_const<decltype(row.gamma)>::type>>::value,
|
||||||
"result fields are accepted and not wrapped");
|
"result fields are accepted and not wrapped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user