diff --git a/include/SQLiteCpp/Column.h b/include/SQLiteCpp/Column.h index a4d1e59..7ad401b 100644 --- a/include/SQLiteCpp/Column.h +++ b/include/SQLiteCpp/Column.h @@ -14,7 +14,7 @@ #include #include -#include +#include // For INT_MAX namespace SQLite @@ -76,7 +76,7 @@ public: #ifdef SQLITE_ENABLE_COLUMN_METADATA /** * @brief Return a pointer to the table column name that is the origin of this result column - * + * * Require definition of the SQLITE_ENABLE_COLUMN_METADATA preprocessor macro : * - when building the SQLite library itself (which is the case for the Debian libsqlite3 binary for instance), * - and also when compiling this wrapper. @@ -187,7 +187,7 @@ public: { return getUInt(); } -#else +#else // sizeof(long)==8 means the data model of the system is LLP64 (64bits Linux) /// Inline cast operator to 64bits long when the data model of the system is ILP64 (Linux 64 bits...) inline operator long() const { diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index 66a013a..e3e651d 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -14,6 +14,7 @@ #include #include +#include // For INT_MAX // Forward declarations to avoid inclusion of in a header struct sqlite3; @@ -123,7 +124,7 @@ public: { bind(aIndex, static_cast(aValue)); } -#else +#else // sizeof(long)==8 means the data model of the system is LLP64 (64bits Linux) /** * @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) */ @@ -205,7 +206,7 @@ public: { bind(apName, static_cast(aValue)); } -#else +#else // sizeof(long)==8 means the data model of the system is LLP64 (64bits Linux) /** * @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) */ @@ -293,7 +294,7 @@ public: { bind(aName.c_str(), static_cast(aValue)); } -#else +#else // sizeof(long)==8 means the data model of the system is LLP64 (64bits Linux) /** * @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1) */ @@ -408,7 +409,7 @@ public: /** * @brief Try to execute a step of the prepared query to fetch one row of results, returning the sqlite result code. * - * + * * * @see exec() execute a one-step prepared statement with no expected result * @see executeStep() execute a step of the prepared query to fetch one row of results diff --git a/tests/Statement_test.cpp b/tests/Statement_test.cpp index f25e08d..2f9e8e6 100644 --- a/tests/Statement_test.cpp +++ b/tests/Statement_test.cpp @@ -19,6 +19,7 @@ #include #include +#include // For INT_MAX TEST(Statement, invalid) { // Create a new database @@ -751,7 +752,7 @@ TEST(Statement, getColumns) { EXPECT_EQ("first", testStruct.msg); EXPECT_EQ(123, testStruct.integer); EXPECT_EQ(0.123, testStruct.real); - + // Get only the first 2 columns auto testStruct2 = query.getColumns(); EXPECT_EQ(1, testStruct2.id); @@ -761,3 +762,16 @@ TEST(Statement, getColumns) { } #endif +#if (LONG_MAX > INT_MAX) // sizeof(long)==8 means the data model of the system is LLP64 (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