getConnectionTimeout of SQLite DB wrapper returns wrong value (in milliseconds, should be in seconds) #1729

This commit is contained in:
Alex Fabijanic 2017-10-12 20:46:53 -05:00
parent 8c336637f9
commit 94e9f2eec2
3 changed files with 7 additions and 2 deletions

View File

@ -73,9 +73,11 @@ public:
void setConnectionTimeout(std::size_t timeout); void setConnectionTimeout(std::size_t timeout);
/// Sets the session connection timeout value. /// Sets the session connection timeout value.
/// Timeout value is in seconds.
std::size_t getConnectionTimeout(); std::size_t getConnectionTimeout();
/// Returns the session connection timeout value. /// Returns the session connection timeout value.
/// Timeout value is in seconds.
void begin(); void begin();
/// Starts a transaction. /// Starts a transaction.
@ -156,7 +158,7 @@ inline const std::string& SessionImpl::connectorName() const
inline std::size_t SessionImpl::getConnectionTimeout() inline std::size_t SessionImpl::getConnectionTimeout()
{ {
return static_cast<std::size_t>(_timeout); return static_cast<std::size_t>(_timeout/1000);
} }

View File

@ -53,7 +53,7 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
_isTransaction(false) _isTransaction(false)
{ {
open(); open();
setConnectionTimeout(CONNECTION_TIMEOUT_DEFAULT); setConnectionTimeout(loginTimeout);
setProperty("handle", _pDB); setProperty("handle", _pDB);
addFeature("autoCommit", addFeature("autoCommit",
&SessionImpl::autoCommit, &SessionImpl::autoCommit,

View File

@ -253,6 +253,9 @@ SQLiteTest::~SQLiteTest()
void SQLiteTest::testBinding() void SQLiteTest::testBinding()
{ {
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db"); Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
assert (tmp.getConnectionTimeout() == Session::LOGIN_TIMEOUT_DEFAULT);
tmp.setConnectionTimeout(5);
assert (tmp.getConnectionTimeout() == 5);
assert (tmp.isConnected()); assert (tmp.isConnected());
std::string tableName("Simpsons"); std::string tableName("Simpsons");
std::string lastName("Simpson"); std::string lastName("Simpson");