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

Fix incorrect for_update function, #583

This commit is contained in:
Roland Bock 2024-07-23 20:58:25 +02:00
parent d6f5e498b9
commit 505adb546a
2 changed files with 5 additions and 3 deletions

View File

@ -162,9 +162,8 @@ namespace sqlpp
return context; return context;
} }
template <typename T> inline auto for_update() -> decltype(statement_t<void, no_for_update_t>().for_update())
auto for_update(T&& t) -> decltype(statement_t<void, no_for_update_t>().for_update(std::forward<T>(t)))
{ {
return statement_t<void, no_for_update_t>().for_update(std::forward<T>(t)); return statement_t<void, no_for_update_t>().for_update();
} }
} // namespace sqlpp } // namespace sqlpp

View File

@ -51,6 +51,9 @@ int ForUpdate(int, char* [])
const auto foo = test::TabFoo{}; const auto foo = test::TabFoo{};
// const auto bar = test::TabBar{}; // const auto bar = test::TabBar{};
compare(__LINE__, sqlpp::for_update(),
" FOR UPDATE ");
// Unconditionally // Unconditionally
compare(__LINE__, select(foo.omega).from(foo).unconditionally().for_update(), compare(__LINE__, select(foo.omega).from(foo).unconditionally().for_update(),
"SELECT tab_foo.omega FROM tab_foo FOR UPDATE "); "SELECT tab_foo.omega FROM tab_foo FOR UPDATE ");