mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-06 10:46:03 -04:00
Merge branch 'master' into windows-migration
This commit is contained in:
commit
bc80914ddf
@ -204,4 +204,7 @@ Version 3.x - 2022
|
|||||||
- #335 from jagerman/older-macos-avoid-std-filesystem
|
- #335 from jagerman/older-macos-avoid-std-filesystem
|
||||||
- #337 Add catkin configuration from ardabbour/master
|
- #337 Add catkin configuration from ardabbour/master
|
||||||
- #339 Allow specifying transaction behaviors DEFERRED, IMMEDIATE, and EXCLUSIVE from jjenkins278/transaction_behavior
|
- #339 Allow specifying transaction behaviors DEFERRED, IMMEDIATE, and EXCLUSIVE from jjenkins278/transaction_behavior
|
||||||
|
- #340 add HTML keywords and properly link up the links in docs/README.md from phoebe-leong/patch-1
|
||||||
|
- #341 Install the package.xml file from ardabbour/patch-1
|
||||||
|
- #352 add basic meson support from ninjaoflight/meson-support
|
||||||
|
- #349 Refactoring of Statement and Column classes from Kacperos155/refactoring-Statement&Column
|
||||||
|
@ -15,13 +15,17 @@
|
|||||||
// c++17: MinGW GCC version > 8
|
// c++17: MinGW GCC version > 8
|
||||||
// c++17: Visual Studio 2017 version 15.7
|
// c++17: Visual Studio 2017 version 15.7
|
||||||
// c++17: macOS unless targetting compatibility with macOS < 10.15
|
// c++17: macOS unless targetting compatibility with macOS < 10.15
|
||||||
|
#ifndef SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
|
||||||
#if __cplusplus >= 201703L
|
#if __cplusplus >= 201703L
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
#if __GNUC__ > 8 // MinGW requires GCC version > 8 for std::filesystem
|
#if __GNUC__ > 8 // MinGW requires GCC version > 8 for std::filesystem
|
||||||
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
|
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
|
||||||
// macOS clang won't less us touch std::filesystem if we're targetting earlier than 10.15
|
// macOS clang won't let us touch std::filesystem if we're targetting earlier than 10.15
|
||||||
|
#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_13_0) && \
|
||||||
|
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
|
||||||
|
// build for iOS clang won't let us touch std::filesystem if we're targetting earlier than iOS 13
|
||||||
#else
|
#else
|
||||||
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
||||||
#endif
|
#endif
|
||||||
@ -33,6 +37,16 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#endif // c++17 and a suitable compiler
|
#endif // c++17 and a suitable compiler
|
||||||
|
|
||||||
|
#else // SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
|
||||||
|
|
||||||
|
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
||||||
|
#include <experimental/filesystem>
|
||||||
|
namespace std {
|
||||||
|
namespace filesystem = experimental::filesystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -707,7 +707,7 @@ private:
|
|||||||
bool mbDone{false}; //!< true when the last executeStep() had no more row to fetch
|
bool mbDone{false}; //!< true when the last executeStep() had no more row to fetch
|
||||||
|
|
||||||
/// Map of columns index by name (mutable so getColumnIndex can be const)
|
/// Map of columns index by name (mutable so getColumnIndex can be const)
|
||||||
mutable std::map<std::string, int> mColumnNames{};
|
mutable std::map<std::string, int> mColumnNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ TEST(Statement, executeStep)
|
|||||||
const int64_t id = query.getColumn(0);
|
const int64_t id = query.getColumn(0);
|
||||||
const std::string msg = query.getColumn(1);
|
const std::string msg = query.getColumn(1);
|
||||||
const int integer = query.getColumn(2);
|
const int integer = query.getColumn(2);
|
||||||
const long integer2= query.getColumn(2);
|
const int64_t integer2= query.getColumn(2);
|
||||||
const double real = query.getColumn(3);
|
const double real = query.getColumn(3);
|
||||||
EXPECT_EQ(1, id);
|
EXPECT_EQ(1, id);
|
||||||
EXPECT_EQ("first", msg);
|
EXPECT_EQ("first", msg);
|
||||||
@ -221,7 +221,7 @@ TEST(Statement, tryExecuteStep)
|
|||||||
const int64_t id = query.getColumn(0);
|
const int64_t id = query.getColumn(0);
|
||||||
const std::string msg = query.getColumn(1);
|
const std::string msg = query.getColumn(1);
|
||||||
const int integer = query.getColumn(2);
|
const int integer = query.getColumn(2);
|
||||||
const long integer2= query.getColumn(2);
|
const int64_t integer2= query.getColumn(2);
|
||||||
const double real = query.getColumn(3);
|
const double real = query.getColumn(3);
|
||||||
EXPECT_EQ(1, id);
|
EXPECT_EQ(1, id);
|
||||||
EXPECT_EQ("first", msg);
|
EXPECT_EQ("first", msg);
|
||||||
@ -371,15 +371,10 @@ TEST(Statement, bindings)
|
|||||||
// reset() without clearbindings()
|
// reset() without clearbindings()
|
||||||
insert.reset();
|
insert.reset();
|
||||||
|
|
||||||
// Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b long long)
|
// Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b int64_t)
|
||||||
{
|
{
|
||||||
const uint32_t uint32 = 4294967295U;
|
const uint32_t uint32 = 4294967295U;
|
||||||
// preprocessor define to force not use long and use instead uint
|
const int64_t integer = -123;
|
||||||
#if NON_AMBIGOUS_OVERLOAD
|
|
||||||
const int integer = -123;
|
|
||||||
#else
|
|
||||||
const long integer = -123;
|
|
||||||
#endif
|
|
||||||
insert.bind(2, uint32);
|
insert.bind(2, uint32);
|
||||||
insert.bind(3, integer);
|
insert.bind(3, integer);
|
||||||
EXPECT_EQ(1, insert.exec());
|
EXPECT_EQ(1, insert.exec());
|
||||||
@ -461,11 +456,11 @@ TEST(Statement, bindByName)
|
|||||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||||
|
|
||||||
// Create a new table
|
// Create a new table
|
||||||
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, int INTEGER, double REAL, long INTEGER)"));
|
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, int INTEGER, long INTEGER, double REAL)"));
|
||||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
||||||
|
|
||||||
// Insertion with bindable parameters
|
// Insertion with bindable parameters
|
||||||
SQLite::Statement insert(db, "INSERT INTO test VALUES (NULL, @msg, @int, @double, @long)");
|
SQLite::Statement insert(db, "INSERT INTO test VALUES (NULL, @msg, @int, @long, @double)");
|
||||||
|
|
||||||
// First row with text/int/double
|
// First row with text/int/double
|
||||||
insert.bind("@msg", "first");
|
insert.bind("@msg", "first");
|
||||||
@ -487,8 +482,8 @@ TEST(Statement, bindByName)
|
|||||||
EXPECT_EQ (1, query.getColumn(0).getInt64());
|
EXPECT_EQ (1, query.getColumn(0).getInt64());
|
||||||
EXPECT_STREQ("first", query.getColumn(1).getText());
|
EXPECT_STREQ("first", query.getColumn(1).getText());
|
||||||
EXPECT_EQ (123, query.getColumn(2).getInt());
|
EXPECT_EQ (123, query.getColumn(2).getInt());
|
||||||
EXPECT_EQ (0.123, query.getColumn(3).getDouble());
|
EXPECT_EQ (-123, query.getColumn(3).getInt());
|
||||||
EXPECT_EQ (-123, query.getColumn(4).getInt());
|
EXPECT_EQ (0.123, query.getColumn(4).getDouble());
|
||||||
|
|
||||||
// reset() with clearbindings() and new bindings
|
// reset() with clearbindings() and new bindings
|
||||||
insert.reset();
|
insert.reset();
|
||||||
@ -497,17 +492,13 @@ TEST(Statement, bindByName)
|
|||||||
// Second row with string/int64/float
|
// Second row with string/int64/float
|
||||||
{
|
{
|
||||||
const std::string second("second");
|
const std::string second("second");
|
||||||
|
const int32_t int32 = -123;
|
||||||
const int64_t int64 = 12345678900000LL;
|
const int64_t int64 = 12345678900000LL;
|
||||||
#if NON_AMBIGOUS_OVERLOAD
|
|
||||||
const int integer = -123;
|
|
||||||
#else
|
|
||||||
const long integer = -123;
|
|
||||||
#endif
|
|
||||||
const float float32 = 0.234f;
|
const float float32 = 0.234f;
|
||||||
insert.bind("@msg", second);
|
insert.bind("@msg", second);
|
||||||
insert.bind("@int", int64);
|
insert.bind("@int", int32);
|
||||||
|
insert.bind("@long", int64);
|
||||||
insert.bind("@double", float32);
|
insert.bind("@double", float32);
|
||||||
insert.bind("@long", integer);
|
|
||||||
EXPECT_EQ(1, insert.exec());
|
EXPECT_EQ(1, insert.exec());
|
||||||
EXPECT_EQ(SQLITE_DONE, db.getErrorCode());
|
EXPECT_EQ(SQLITE_DONE, db.getErrorCode());
|
||||||
|
|
||||||
@ -517,9 +508,9 @@ TEST(Statement, bindByName)
|
|||||||
EXPECT_FALSE(query.isDone());
|
EXPECT_FALSE(query.isDone());
|
||||||
EXPECT_EQ(2, query.getColumn(0).getInt64());
|
EXPECT_EQ(2, query.getColumn(0).getInt64());
|
||||||
EXPECT_EQ(second, query.getColumn(1).getText());
|
EXPECT_EQ(second, query.getColumn(1).getText());
|
||||||
EXPECT_EQ(12345678900000LL, query.getColumn(2).getInt64());
|
EXPECT_EQ(-123, query.getColumn(2).getInt());
|
||||||
EXPECT_EQ(0.234f, query.getColumn(3).getDouble());
|
EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64());
|
||||||
EXPECT_EQ(-123, query.getColumn(4).getInt());
|
EXPECT_EQ(0.234f, query.getColumn(4).getDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset() without clearbindings()
|
// reset() without clearbindings()
|
||||||
@ -540,7 +531,7 @@ TEST(Statement, bindByName)
|
|||||||
EXPECT_STREQ(buffer, query.getColumn(1).getText());
|
EXPECT_STREQ(buffer, query.getColumn(1).getText());
|
||||||
EXPECT_TRUE (query.isColumnNull(2));
|
EXPECT_TRUE (query.isColumnNull(2));
|
||||||
EXPECT_EQ(0, query.getColumn(2).getInt());
|
EXPECT_EQ(0, query.getColumn(2).getInt());
|
||||||
EXPECT_EQ(0.234f, query.getColumn(3).getDouble());
|
EXPECT_EQ(0.234f, query.getColumn(4).getDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset() without clearbindings()
|
// reset() without clearbindings()
|
||||||
@ -561,7 +552,7 @@ TEST(Statement, bindByName)
|
|||||||
EXPECT_FALSE(query.isDone());
|
EXPECT_FALSE(query.isDone());
|
||||||
EXPECT_EQ(4, query.getColumn(0).getInt64());
|
EXPECT_EQ(4, query.getColumn(0).getInt64());
|
||||||
EXPECT_EQ(4294967295U, query.getColumn(2).getUInt());
|
EXPECT_EQ(4294967295U, query.getColumn(2).getUInt());
|
||||||
EXPECT_EQ(12345678900000LL, query.getColumn(4).getInt64());
|
EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,11 +606,7 @@ TEST(Statement, bindByNameString)
|
|||||||
{
|
{
|
||||||
const std::string second("second");
|
const std::string second("second");
|
||||||
const int64_t int64 = 12345678900000LL;
|
const int64_t int64 = 12345678900000LL;
|
||||||
#if NON_AMBIGOUS_OVERLOAD
|
const int64_t integer = -123;
|
||||||
const int integer = -123;
|
|
||||||
#else
|
|
||||||
const long integer = -123;
|
|
||||||
#endif
|
|
||||||
const float float32 = 0.234f;
|
const float float32 = 0.234f;
|
||||||
insert.bind(amsg, second);
|
insert.bind(amsg, second);
|
||||||
insert.bind(aint, int64);
|
insert.bind(aint, int64);
|
||||||
@ -1024,21 +1011,6 @@ TEST(Statement, getColumns)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (LONG_MAX > INT_MAX) // sizeof(long)==8 means the data model of the system is LP64 (64bits Linux)
|
|
||||||
TEST(Statement, bind64bitsLong)
|
|
||||||
{
|
|
||||||
// Create a new database
|
|
||||||
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
|
||||||
EXPECT_EQ(SQLite::OK, db.getErrorCode());
|
|
||||||
EXPECT_EQ(SQLite::OK, db.getExtendedErrorCode());
|
|
||||||
|
|
||||||
SQLite::Statement query(db, "SELECT ?");
|
|
||||||
query.bind(1, 4294967297L);
|
|
||||||
query.executeStep();
|
|
||||||
EXPECT_EQ(4294967297L, query.getColumn(0).getInt64());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST(Statement, getBindParameterCount)
|
TEST(Statement, getBindParameterCount)
|
||||||
{
|
{
|
||||||
// Create a new database
|
// Create a new database
|
||||||
|
Loading…
x
Reference in New Issue
Block a user