Skip to content

Commit 61fbd8c

Browse files
committed
0.7.25: fix
1 parent 967b82d commit 61fbd8c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/database/database.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
#include <fmt/core.h>
44
#include <trantor/utils/Logger.h>
55

6-
#include <chrono>
76
#include <cstdlib>
87
#include <exception>
98
#include <jsoncons/basic_json.hpp>
109
#include <jsoncons/json.hpp>
1110
#include <memory>
1211
#include <optional>
1312
#include <string>
14-
#include <thread>
1513
#include <type_traits>
1614
#include <unordered_set>
1715
#include <utility>
@@ -44,9 +42,12 @@ bool Database::checkExists(const std::string &table, const std::string &column,
4442
{
4543
try
4644
{
47-
IUGUARD
48-
pqxx::nontransaction txn(*connection);
49-
pqxx::result result = txn.exec(fmt::format("SELECT EXISTS (SELECT 1 FROM {} WHERE {} = '{}');", table, column, value));
45+
pqxx::result result;
46+
{
47+
IUGUARD
48+
pqxx::nontransaction txn(*connection);
49+
result = txn.exec(fmt::format("SELECT EXISTS (SELECT 1 FROM {} WHERE {} = '{}');", table, column, value));
50+
}
5051
return result[0][0].as<bool>();
5152
}
5253
catch (const std::exception &e)

0 commit comments

Comments
 (0)