diff --git a/orm_lib/src/postgresql_impl/PgTransactionImpl.cc b/orm_lib/src/postgresql_impl/PgTransactionImpl.cc index a0a57c3e..d65ac738 100644 --- a/orm_lib/src/postgresql_impl/PgTransactionImpl.cc +++ b/orm_lib/src/postgresql_impl/PgTransactionImpl.cc @@ -24,6 +24,7 @@ PgTransactionImpl::PgTransactionImpl(const PgConnectionPtr &connPtr, } PgTransactionImpl::~PgTransactionImpl() { + LOG_TRACE << "Destruct"; assert(!_isWorking); if (!_isCommitedOrRolledback) { diff --git a/orm_lib/src/postgresql_impl/test/test2.cc b/orm_lib/src/postgresql_impl/test/test2.cc index 230300b1..25b02b11 100644 --- a/orm_lib/src/postgresql_impl/test/test2.cc +++ b/orm_lib/src/postgresql_impl/test/test2.cc @@ -36,20 +36,15 @@ int main() { auto trans = client->newTransaction(); *trans << "delete from users where user_uuid=201" >> - [](const Result &r) { + [trans](const Result &r) { std::cout << "delete " << r.affectedRows() << "user!!!!!" << std::endl; + trans->rollback(); } >> [](const DrogonDbException &e) { std::cout << e.base().what() << std::endl; }; - *trans << "dlelf from users" >> - [](const Result &r) { - std::cout << "delete " << r.affectedRows() << "user!!!!!" << std::endl; - } >> - [](const DrogonDbException &e) { - std::cout << e.base().what() << std::endl; - }; - *trans << "dlelf111 from users" >> + + *trans << "delete from users where user_uuid=201" >> [](const Result &r) { std::cout << "delete " << r.affectedRows() << "user!!!!!" << std::endl; } >> @@ -57,6 +52,7 @@ int main() std::cout << e.base().what() << std::endl; }; } + Mapper mapper(client); auto U = mapper.findByPrimaryKey(2); std::cout << "id=" << U._userId << std::endl;