0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

Single column select has a value type

This commit is contained in:
Roland Bock 2024-07-15 07:44:29 +02:00
parent 6c1d59ffc4
commit 2d2f08007a
3 changed files with 11 additions and 4 deletions

View File

@ -54,7 +54,7 @@ namespace sqlpp
template <typename Column>
struct select_traits<Column>
{
using _traits = make_traits<value_type_of_t<remove_optional_t<Column>>,
using _traits = make_traits<value_type_of_t<Column>,
tag::is_select_column_list,
tag::is_return_value,
tag::is_expression,
@ -228,6 +228,9 @@ namespace sqlpp
};
};
template <typename Column>
struct value_type_of<select_column_list_t<Column>> : public value_type_of<Column> {};
namespace detail
{
template <typename... Columns>

View File

@ -264,6 +264,9 @@ namespace sqlpp
}
};
template<typename... Policies>
struct value_type_of<statement_t<Policies...>> : value_type_of<typename detail::statement_policies_t<Policies...>> {};
template <typename Context, typename... Policies>
Context& serialize(const statement_t<Policies...>& t, Context& context)
{

View File

@ -46,24 +46,25 @@ void test_in_expression(Value v)
auto v_not_null = sqlpp::value(v);
auto v_maybe_null = sqlpp::value(sqlpp::compat::make_optional(v));
#warning : Need to support in with select
// in(v_not_null, select(v_not_null.as(sqlpp::alias::a)));
// Compare non-nullable with non-nullable.
static_assert(is_bool<decltype(in(v_not_null, std::make_tuple(v_not_null, v_not_null)))>::value, "");
static_assert(is_bool<decltype(in(v_not_null, std::vector<Value>{}))>::value, "");
static_assert(is_bool<decltype(in(v_not_null, select(v_not_null.as(sqlpp::alias::a))))>::value, "");
// Compare non-nullable with nullable.
static_assert(is_maybe_bool<decltype(in(v_not_null, std::make_tuple(v_not_null, v_maybe_null)))>::value, "");
static_assert(is_maybe_bool<decltype(in(v_not_null, std::vector<OptValue>{}))>::value, "");
static_assert(is_maybe_bool<decltype(in(v_not_null, select(v_maybe_null.as(sqlpp::alias::a))))>::value, "");
// Compare nullable with non-nullable.
static_assert(is_maybe_bool<decltype(in(v_maybe_null, std::make_tuple(v_not_null, v_not_null)))>::value, "");
static_assert(is_maybe_bool<decltype(in(v_maybe_null, std::vector<Value>{}))>::value, "");
static_assert(is_maybe_bool<decltype(in(v_maybe_null, select(v_not_null.as(sqlpp::alias::a))))>::value, "");
// Compare nullable with nullable.
static_assert(is_maybe_bool<decltype(in(v_maybe_null, std::make_tuple(v_not_null, v_maybe_null)))>::value, "");
static_assert(is_maybe_bool<decltype(in(v_maybe_null, std::vector<OptValue>{}))>::value, "");
static_assert(is_maybe_bool<decltype(in(v_maybe_null, select(v_maybe_null.as(sqlpp::alias::a))))>::value, "");
}
template<typename Value>