mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Add Statement binding for long int values to Fix #147
This commit is contained in:
parent
eb065bf741
commit
a3160dcfc2
@ -114,6 +114,25 @@ public:
|
|||||||
* @brief Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
|
* @brief Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
|
||||||
*/
|
*/
|
||||||
void bind(const int aIndex, const unsigned aValue);
|
void bind(const int aIndex, const unsigned aValue);
|
||||||
|
|
||||||
|
#if (LONG_MAX == INT_MAX) // sizeof(long)==4 means the data model of the system is ILP32 (32bits OS or Windows 64bits)
|
||||||
|
/**
|
||||||
|
* @brief Bind a 32bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
|
||||||
|
*/
|
||||||
|
void bind(const int aIndex, const long aValue)
|
||||||
|
{
|
||||||
|
bind(aIndex, static_cast<int>(aValue));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
|
||||||
|
*/
|
||||||
|
void bind(const int aIndex, const long aValue)
|
||||||
|
{
|
||||||
|
bind(aIndex, static_cast<long long>(aValue));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
|
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
|
||||||
*/
|
*/
|
||||||
|
@ -320,10 +320,12 @@ TEST(Statement, bindings) {
|
|||||||
// reset() without clearbindings()
|
// reset() without clearbindings()
|
||||||
insert.reset();
|
insert.reset();
|
||||||
|
|
||||||
// Sixth row with uint32_t unsigned value
|
// Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b long long)
|
||||||
{
|
{
|
||||||
const uint32_t uint32 = 4294967295U;
|
const uint32_t uint32 = 4294967295U;
|
||||||
|
const long integer = -123;
|
||||||
insert.bind(2, uint32);
|
insert.bind(2, uint32);
|
||||||
|
insert.bind(3, integer);
|
||||||
EXPECT_EQ(1, insert.exec());
|
EXPECT_EQ(1, insert.exec());
|
||||||
EXPECT_EQ(SQLITE_DONE, db.getErrorCode());
|
EXPECT_EQ(SQLITE_DONE, db.getErrorCode());
|
||||||
|
|
||||||
@ -333,6 +335,7 @@ TEST(Statement, bindings) {
|
|||||||
EXPECT_FALSE(query.isDone());
|
EXPECT_FALSE(query.isDone());
|
||||||
EXPECT_EQ(6, query.getColumn(0).getInt64());
|
EXPECT_EQ(6, query.getColumn(0).getInt64());
|
||||||
EXPECT_EQ(4294967295U, query.getColumn(2).getUInt());
|
EXPECT_EQ(4294967295U, query.getColumn(2).getUInt());
|
||||||
|
EXPECT_EQ(-123, query.getColumn(3).getInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user