Fix missing wrap_operand in case/then/else_, #624

case(...).then(...).else_(7) can now be used.
This commit is contained in:
Roland Bock
2025-06-24 12:04:09 +02:00
parent 5e930f3901
commit 6b6b5cc4fb
2 changed files with 7 additions and 1 deletions

View File

@@ -86,7 +86,7 @@ namespace sqlpp
class case_then_t
{
template <typename Else>
auto _else_impl(consistent_t /*unused*/, Else else_) -> case_t<When, Then, Else>
auto _else_impl(consistent_t /*unused*/, Else else_) -> case_t<When, Then, wrap_operand_t<Else>>
{
return {_when, _then, else_};
}

View File

@@ -197,6 +197,12 @@ int Select(int, char*[])
std::cerr << row.beta << std::endl;
}
for (const auto& row :
db(select(sqlpp::case_when(true).then(5).else_(7).as(t.beta)).from(t).unconditionally()))
{
std::cerr << row.beta << std::endl;
}
for (const auto& row : db(select(all_of(t)).from(t).unconditionally()))
{
for_each_field(row, to_cerr{});