Fix a bug in the Mapper::insertFuture() (#620)
This commit is contained in:
parent
dbf21f7dbc
commit
594911b7a2
|
@ -1243,8 +1243,15 @@ inline std::future<T> Mapper<T>::insertFuture(const T &obj) noexcept
|
|||
tmp.findByPrimaryKey(
|
||||
newObj.getPrimaryKey(),
|
||||
[prom](T selObj) { prom->set_value(selObj); },
|
||||
[prom](const std::exception_ptr &e) {
|
||||
prom->set_exception(e);
|
||||
[prom](const DrogonDbException &e) {
|
||||
try
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
prom->set_exception(std::current_exception());
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
|
|
@ -31,7 +31,7 @@ using namespace drogon::orm;
|
|||
#define RED "\033[31m" /* Red */
|
||||
#define GREEN "\033[32m" /* Green */
|
||||
|
||||
constexpr int postgre_tests = 43;
|
||||
constexpr int postgre_tests = 44;
|
||||
constexpr int mysql_tests = 45;
|
||||
constexpr int sqlite_tests = 47;
|
||||
|
||||
|
@ -650,13 +650,30 @@ void doPostgreTest(const drogon::orm::DbClientPtr &clientPtr)
|
|||
testOutput(false,
|
||||
"postgresql - ORM mapper asynchronous interface(0)");
|
||||
});
|
||||
|
||||
/// 6.1.5 insert future
|
||||
user.setUserId("pg_future");
|
||||
auto fu = mapper.insertFuture(user);
|
||||
try
|
||||
{
|
||||
auto u = fu.get();
|
||||
testOutput(true,
|
||||
"postgresql - ORM mapper asynchronous future interface(0)");
|
||||
}
|
||||
catch (const DrogonDbException &e)
|
||||
{
|
||||
std::cerr << e.base().what() << std::endl;
|
||||
testOutput(false,
|
||||
"postgresql - ORM mapper asynchronous future interface(0)");
|
||||
}
|
||||
|
||||
/// 6.2 insert
|
||||
user.setUserId("pg1");
|
||||
user.setUserName("postgres1");
|
||||
mapper.insert(
|
||||
user,
|
||||
[](Users ret) {
|
||||
testOutput(ret.getPrimaryKey() == 2,
|
||||
testOutput(ret.getPrimaryKey() == 3,
|
||||
"postgresql - ORM mapper asynchronous interface(1)");
|
||||
},
|
||||
[](const DrogonDbException &e) {
|
||||
|
|
Loading…
Reference in New Issue