Skip to content

Commit

Permalink
fix(SQLite): windows build (global var does not link) #3018
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed May 30, 2022
1 parent 1a662a1 commit d93a188
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
18 changes: 0 additions & 18 deletions Data/SQLite/include/Poco/Data/SQLite/SQLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,5 @@
#endif
#endif

//
// SQLite Transaction type
//

namespace Poco {
namespace Data {
namespace SQLite {

extern const std::string TRANSACTION_TYPE_PROPERTY_KEY;

enum class TransactionType
{
DEFERRED,
EXCLUSIVE,
IMMEDIATE
};

} } } // namespace Poco::Data::SQLite

#endif // SQLite_SQLite_INCLUDED
2 changes: 2 additions & 0 deletions Data/SQLite/include/Poco/Data/SQLite/SessionImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/SQLite/Utility.h"
#include "Poco/Data/SQLite/Connector.h"
#include "Poco/Data/SQLite/Binder.h"
#include "Poco/Data/AbstractSessionImpl.h"
Expand Down Expand Up @@ -119,6 +120,7 @@ class SQLite_API SessionImpl: public Poco::Data::AbstractSessionImpl<SessionImpl

void setTransactionType(TransactionType transactionType);
/// Sets begin transaction type for the session.

TransactionType getTransactionType() const;
/// Returns begin transaction type.

Expand Down
14 changes: 14 additions & 0 deletions Data/SQLite/include/Poco/Data/SQLite/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ class SQLite_API Utility
/// Various utility functions for SQLite.
{
public:

// SQLite Transaction type
static const std::string TRANSACTION_TYPE_PROPERTY_KEY;

enum class TransactionType
{
DEFERRED,
EXCLUSIVE,
IMMEDIATE
};

static const std::string SQLITE_DATE_FORMAT;
static const std::string SQLITE_TIME_FORMAT;
typedef std::map<std::string, MetaColumn::ColumnDataType> TypeMap;
Expand Down Expand Up @@ -210,6 +221,9 @@ class SQLite_API Utility
};


using TransactionType = Utility::TransactionType;


//
// inlines
//
Expand Down
4 changes: 2 additions & 2 deletions Data/SQLite/src/SessionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Poco {
namespace Data {
namespace SQLite {

const std::string TRANSACTION_TYPE_PROPERTY_KEY = "transactionType";

const std::string SessionImpl::DEFERRED_BEGIN_TRANSACTION("BEGIN DEFERRED");
const std::string SessionImpl::EXCLUSIVE_BEGIN_TRANSACTION("BEGIN EXCLUSIVE");
const std::string SessionImpl::IMMEDIATE_BEGIN_TRANSACTION("BEGIN IMMEDIATE");
Expand All @@ -61,7 +61,7 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
&SessionImpl::autoCommit,
&SessionImpl::isAutoCommit);
addProperty("connectionTimeout", &SessionImpl::setConnectionTimeout, &SessionImpl::getConnectionTimeout);
addProperty(TRANSACTION_TYPE_PROPERTY_KEY, &SessionImpl::setTransactionType, &SessionImpl::getTransactionType);
addProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY, &SessionImpl::setTransactionType, &SessionImpl::getTransactionType);
}


Expand Down
2 changes: 2 additions & 0 deletions Data/SQLite/src/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace Data {
namespace SQLite {


const std::string Utility::TRANSACTION_TYPE_PROPERTY_KEY = "transactionType";

const int Utility::THREAD_MODE_SINGLE = SQLITE_CONFIG_SINGLETHREAD;
const int Utility::THREAD_MODE_MULTI = SQLITE_CONFIG_MULTITHREAD;
const int Utility::THREAD_MODE_SERIAL = SQLITE_CONFIG_SERIALIZED;
Expand Down
10 changes: 6 additions & 4 deletions Data/SQLite/testsuite/src/SQLiteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3205,7 +3205,8 @@ void SQLiteTest::testTransaction()
std::string result;

session.setTransactionIsolation(Session::TRANSACTION_READ_COMMITTED);
session.setProperty(Poco::Data::SQLite::TRANSACTION_TYPE_PROPERTY_KEY, Poco::Data::SQLite::TransactionType::EXCLUSIVE);
session.setProperty(Poco::Data::SQLite::Utility::TRANSACTION_TYPE_PROPERTY_KEY,
Poco::Data::SQLite::TransactionType::EXCLUSIVE);
{
Transaction trans(session);
assertTrue (trans.isActive());
Expand All @@ -3227,7 +3228,8 @@ void SQLiteTest::testTransaction()
session << "SELECT count(*) FROM Person", into(count), now;
assertTrue (0 == count);
assertTrue (!session.isTransaction());
session.setProperty(Poco::Data::SQLite::TRANSACTION_TYPE_PROPERTY_KEY, Poco::Data::SQLite::TransactionType::IMMEDIATE);
session.setProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY,
Poco::Data::SQLite::TransactionType::IMMEDIATE);
{
Transaction trans(session);
session << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now;
Expand Down Expand Up @@ -3442,8 +3444,8 @@ void SQLiteTest::testTransactionTypeProperty()
using namespace Poco::Data::SQLite;

Session tmp(Connector::KEY, "dummy.db");
tmp.setProperty(TRANSACTION_TYPE_PROPERTY_KEY, TransactionType::EXCLUSIVE);
Poco::Any property = tmp.getProperty(TRANSACTION_TYPE_PROPERTY_KEY);
tmp.setProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY, TransactionType::EXCLUSIVE);
Poco::Any property = tmp.getProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY);
TransactionType value = Poco::RefAnyCast<TransactionType>(property);
assertTrue(value == TransactionType::EXCLUSIVE);
} catch (Poco::Exception&) {}
Expand Down

0 comments on commit d93a188

Please sign in to comment.