Skip to content

Commit bc80914

Browse files
authored
Merge branch 'master' into windows-migration
2 parents e32daec + 7d8b69e commit bc80914

File tree

4 files changed

+37
-48
lines changed

4 files changed

+37
-48
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,7 @@ Version 3.x - 2022
204204
- #335 from jagerman/older-macos-avoid-std-filesystem
205205
- #337 Add catkin configuration from ardabbour/master
206206
- #339 Allow specifying transaction behaviors DEFERRED, IMMEDIATE, and EXCLUSIVE from jjenkins278/transaction_behavior
207-
207+
- #340 add HTML keywords and properly link up the links in docs/README.md from phoebe-leong/patch-1
208+
- #341 Install the package.xml file from ardabbour/patch-1
209+
- #352 add basic meson support from ninjaoflight/meson-support
210+
- #349 Refactoring of Statement and Column classes from Kacperos155/refactoring-Statement&Column

include/SQLiteCpp/Database.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
// c++17: MinGW GCC version > 8
1616
// c++17: Visual Studio 2017 version 15.7
1717
// c++17: macOS unless targetting compatibility with macOS < 10.15
18+
#ifndef SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
1819
#if __cplusplus >= 201703L
1920
#if defined(__MINGW32__) || defined(__MINGW64__)
2021
#if __GNUC__ > 8 // MinGW requires GCC version > 8 for std::filesystem
2122
#define SQLITECPP_HAVE_STD_FILESYSTEM
2223
#endif
2324
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
24-
// macOS clang won't less us touch std::filesystem if we're targetting earlier than 10.15
25+
// macOS clang won't let us touch std::filesystem if we're targetting earlier than 10.15
26+
#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_13_0) && \
27+
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
28+
// build for iOS clang won't let us touch std::filesystem if we're targetting earlier than iOS 13
2529
#else
2630
#define SQLITECPP_HAVE_STD_FILESYSTEM
2731
#endif
@@ -33,6 +37,16 @@
3337
#include <filesystem>
3438
#endif // c++17 and a suitable compiler
3539

40+
#else // SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
41+
42+
#define SQLITECPP_HAVE_STD_FILESYSTEM
43+
#include <experimental/filesystem>
44+
namespace std {
45+
namespace filesystem = experimental::filesystem;
46+
}
47+
48+
#endif // SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
49+
3650
#include <memory>
3751
#include <string.h>
3852

include/SQLiteCpp/Statement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ class Statement
707707
bool mbDone{false}; //!< true when the last executeStep() had no more row to fetch
708708

709709
/// Map of columns index by name (mutable so getColumnIndex can be const)
710-
mutable std::map<std::string, int> mColumnNames{};
710+
mutable std::map<std::string, int> mColumnNames;
711711
};
712712

713713

tests/Statement_test.cpp

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ TEST(Statement, executeStep)
168168
const int64_t id = query.getColumn(0);
169169
const std::string msg = query.getColumn(1);
170170
const int integer = query.getColumn(2);
171-
const long integer2= query.getColumn(2);
171+
const int64_t integer2= query.getColumn(2);
172172
const double real = query.getColumn(3);
173173
EXPECT_EQ(1, id);
174174
EXPECT_EQ("first", msg);
@@ -221,7 +221,7 @@ TEST(Statement, tryExecuteStep)
221221
const int64_t id = query.getColumn(0);
222222
const std::string msg = query.getColumn(1);
223223
const int integer = query.getColumn(2);
224-
const long integer2= query.getColumn(2);
224+
const int64_t integer2= query.getColumn(2);
225225
const double real = query.getColumn(3);
226226
EXPECT_EQ(1, id);
227227
EXPECT_EQ("first", msg);
@@ -371,15 +371,10 @@ TEST(Statement, bindings)
371371
// reset() without clearbindings()
372372
insert.reset();
373373

374-
// Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b long long)
374+
// Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b int64_t)
375375
{
376376
const uint32_t uint32 = 4294967295U;
377-
// preprocessor define to force not use long and use instead uint
378-
#if NON_AMBIGOUS_OVERLOAD
379-
const int integer = -123;
380-
#else
381-
const long integer = -123;
382-
#endif
377+
const int64_t integer = -123;
383378
insert.bind(2, uint32);
384379
insert.bind(3, integer);
385380
EXPECT_EQ(1, insert.exec());
@@ -461,11 +456,11 @@ TEST(Statement, bindByName)
461456
EXPECT_EQ(SQLite::OK, db.getErrorCode());
462457

463458
// Create a new table
464-
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, int INTEGER, double REAL, long INTEGER)"));
459+
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT, int INTEGER, long INTEGER, double REAL)"));
465460
EXPECT_EQ(SQLite::OK, db.getErrorCode());
466461

467462
// Insertion with bindable parameters
468-
SQLite::Statement insert(db, "INSERT INTO test VALUES (NULL, @msg, @int, @double, @long)");
463+
SQLite::Statement insert(db, "INSERT INTO test VALUES (NULL, @msg, @int, @long, @double)");
469464

470465
// First row with text/int/double
471466
insert.bind("@msg", "first");
@@ -487,8 +482,8 @@ TEST(Statement, bindByName)
487482
EXPECT_EQ (1, query.getColumn(0).getInt64());
488483
EXPECT_STREQ("first", query.getColumn(1).getText());
489484
EXPECT_EQ (123, query.getColumn(2).getInt());
490-
EXPECT_EQ (0.123, query.getColumn(3).getDouble());
491-
EXPECT_EQ (-123, query.getColumn(4).getInt());
485+
EXPECT_EQ (-123, query.getColumn(3).getInt());
486+
EXPECT_EQ (0.123, query.getColumn(4).getDouble());
492487

493488
// reset() with clearbindings() and new bindings
494489
insert.reset();
@@ -497,17 +492,13 @@ TEST(Statement, bindByName)
497492
// Second row with string/int64/float
498493
{
499494
const std::string second("second");
495+
const int32_t int32 = -123;
500496
const int64_t int64 = 12345678900000LL;
501-
#if NON_AMBIGOUS_OVERLOAD
502-
const int integer = -123;
503-
#else
504-
const long integer = -123;
505-
#endif
506497
const float float32 = 0.234f;
507498
insert.bind("@msg", second);
508-
insert.bind("@int", int64);
499+
insert.bind("@int", int32);
500+
insert.bind("@long", int64);
509501
insert.bind("@double", float32);
510-
insert.bind("@long", integer);
511502
EXPECT_EQ(1, insert.exec());
512503
EXPECT_EQ(SQLITE_DONE, db.getErrorCode());
513504

@@ -517,9 +508,9 @@ TEST(Statement, bindByName)
517508
EXPECT_FALSE(query.isDone());
518509
EXPECT_EQ(2, query.getColumn(0).getInt64());
519510
EXPECT_EQ(second, query.getColumn(1).getText());
520-
EXPECT_EQ(12345678900000LL, query.getColumn(2).getInt64());
521-
EXPECT_EQ(0.234f, query.getColumn(3).getDouble());
522-
EXPECT_EQ(-123, query.getColumn(4).getInt());
511+
EXPECT_EQ(-123, query.getColumn(2).getInt());
512+
EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64());
513+
EXPECT_EQ(0.234f, query.getColumn(4).getDouble());
523514
}
524515

525516
// reset() without clearbindings()
@@ -540,7 +531,7 @@ TEST(Statement, bindByName)
540531
EXPECT_STREQ(buffer, query.getColumn(1).getText());
541532
EXPECT_TRUE (query.isColumnNull(2));
542533
EXPECT_EQ(0, query.getColumn(2).getInt());
543-
EXPECT_EQ(0.234f, query.getColumn(3).getDouble());
534+
EXPECT_EQ(0.234f, query.getColumn(4).getDouble());
544535
}
545536

546537
// reset() without clearbindings()
@@ -561,7 +552,7 @@ TEST(Statement, bindByName)
561552
EXPECT_FALSE(query.isDone());
562553
EXPECT_EQ(4, query.getColumn(0).getInt64());
563554
EXPECT_EQ(4294967295U, query.getColumn(2).getUInt());
564-
EXPECT_EQ(12345678900000LL, query.getColumn(4).getInt64());
555+
EXPECT_EQ(12345678900000LL, query.getColumn(3).getInt64());
565556
}
566557
}
567558

@@ -615,11 +606,7 @@ TEST(Statement, bindByNameString)
615606
{
616607
const std::string second("second");
617608
const int64_t int64 = 12345678900000LL;
618-
#if NON_AMBIGOUS_OVERLOAD
619-
const int integer = -123;
620-
#else
621-
const long integer = -123;
622-
#endif
609+
const int64_t integer = -123;
623610
const float float32 = 0.234f;
624611
insert.bind(amsg, second);
625612
insert.bind(aint, int64);
@@ -1024,21 +1011,6 @@ TEST(Statement, getColumns)
10241011
}
10251012
#endif
10261013

1027-
#if (LONG_MAX > INT_MAX) // sizeof(long)==8 means the data model of the system is LP64 (64bits Linux)
1028-
TEST(Statement, bind64bitsLong)
1029-
{
1030-
// Create a new database
1031-
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
1032-
EXPECT_EQ(SQLite::OK, db.getErrorCode());
1033-
EXPECT_EQ(SQLite::OK, db.getExtendedErrorCode());
1034-
1035-
SQLite::Statement query(db, "SELECT ?");
1036-
query.bind(1, 4294967297L);
1037-
query.executeStep();
1038-
EXPECT_EQ(4294967297L, query.getColumn(0).getInt64());
1039-
}
1040-
#endif
1041-
10421014
TEST(Statement, getBindParameterCount)
10431015
{
10441016
// Create a new database

0 commit comments

Comments
 (0)