Created
March 29, 2015 20:28
-
-
Save aleks-f/559603822f1a2f6c762e to your computer and use it in GitHub Desktop.
diff for Poco GH #703: https://github.com/pocoproject/poco/issues/703
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Data/SQLite/src/Utility.cpp b/Data/SQLite/src/Utility.cpp | |
index 8bf46ee..0cd9039 100644 | |
--- a/Data/SQLite/src/Utility.cpp | |
+++ b/Data/SQLite/src/Utility.cpp | |
@@ -86,7 +86,7 @@ Utility::Utility() | |
_types.insert(TypeMap::value_type("UINTEGER32", MetaColumn::FDT_UINT32)); | |
_types.insert(TypeMap::value_type("INT", MetaColumn::FDT_INT32)); | |
_types.insert(TypeMap::value_type("INT32", MetaColumn::FDT_INT32)); | |
- _types.insert(TypeMap::value_type("INTEGER", MetaColumn::FDT_INT32)); | |
+ _types.insert(TypeMap::value_type("INTEGER", MetaColumn::FDT_INT64)); | |
_types.insert(TypeMap::value_type("INTEGER32", MetaColumn::FDT_INT32)); | |
_types.insert(TypeMap::value_type("UINT64", MetaColumn::FDT_UINT64)); | |
_types.insert(TypeMap::value_type("ULONG", MetaColumn::FDT_INT64)); | |
diff --git a/Data/SQLite/testsuite/src/SQLiteTest.cpp b/Data/SQLite/testsuite/src/SQLiteTest.cpp | |
index 25107f1..67bfadd 100644 | |
--- a/Data/SQLite/testsuite/src/SQLiteTest.cpp | |
+++ b/Data/SQLite/testsuite/src/SQLiteTest.cpp | |
@@ -83,6 +83,7 @@ using Poco::NotImplementedException; | |
using Poco::Data::SQLite::ConstraintViolationException; | |
using Poco::Data::SQLite::ParameterCountMismatchException; | |
using Poco::Int32; | |
+using Poco::Int64; | |
using Poco::Dynamic::Var; | |
using Poco::Data::SQLite::Utility; | |
using Poco::delegate; | |
@@ -1910,32 +1911,41 @@ void SQLiteTest::testDateTime() | |
} | |
+#if defined(POCO_PTR_IS_64_BIT) && (POCO_PTR_IS_64_BIT == 1) | |
+ | |
void SQLiteTest::testInternalExtraction() | |
{ | |
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db"); | |
tmp << "DROP TABLE IF EXISTS Vectors", now; | |
- tmp << "CREATE TABLE Vectors (int0 INTEGER, flt0 REAL, str0 VARCHAR)", now; | |
+ tmp << "CREATE TABLE Vectors (int0 INTEGER32, flt0 REAL, str0 VARCHAR, int1 INTEGER)", now; | |
- std::vector<Tuple<int, double, std::string> > v; | |
- v.push_back(Tuple<int, double, std::string>(1, 1.5, "3")); | |
- v.push_back(Tuple<int, double, std::string>(2, 2.5, "4")); | |
- v.push_back(Tuple<int, double, std::string>(3, 3.5, "5")); | |
- v.push_back(Tuple<int, double, std::string>(4, 4.5, "6")); | |
+ typedef Tuple<int, double, std::string, Int64> T; | |
+ std::vector<T> v; | |
+ v.push_back(T(1, 1.5, "3", Int64(1))); | |
+ v.push_back(T(2, 2.5, "4", Int64(2))); | |
+ v.push_back(T(3, 3.5, "5", Int64(3))); | |
+ v.push_back(T(4, 4.5, "6", Int64(std::numeric_limits<Int64>::max()))); | |
- tmp << "INSERT INTO Vectors VALUES (?,?,?)", use(v), now; | |
+ tmp << "INSERT INTO Vectors VALUES (?,?,?,?)", use(v), now; | |
Statement stmt = (tmp << "SELECT * FROM Vectors", now); | |
RecordSet rset(stmt); | |
- assert (3 == rset.columnCount()); | |
+ assert (4 == rset.columnCount()); | |
assert (4 == rset.rowCount()); | |
RecordSet rset2(rset); | |
- assert (3 == rset2.columnCount()); | |
+ assert (4 == rset2.columnCount()); | |
assert (4 == rset2.rowCount()); | |
Int32 a = rset.value<Int32>(0,2); | |
assert (3 == a); | |
+ Int64 x = rset.value<Int64>(3, 2); | |
+ assert(3 == x); | |
+ | |
+ x = rset.value<Int64>(3, 3); | |
+ assert(std::numeric_limits<Int64>::max() == x); | |
+ | |
int c = rset2.value(0); | |
assert (1 == c); | |
@@ -1975,6 +1985,75 @@ void SQLiteTest::testInternalExtraction() | |
catch (RangeException&) { } | |
} | |
+#else // !POCO_PTR_IS_64_BIT | |
+ | |
+void SQLiteTest::testInternalExtraction() | |
+{ | |
+ Session tmp(Poco::Data::SQLite::Connector::KEY, "dummy.db"); | |
+ tmp << "DROP TABLE IF EXISTS Vectors", now; | |
+ tmp << "CREATE TABLE Vectors (int0 INTEGER, flt0 REAL, str0 VARCHAR)", now; | |
+ | |
+ std::vector<Tuple<int, double, std::string> > v; | |
+ v.push_back(Tuple<int, double, std::string>(1, 1.5, "3")); | |
+ v.push_back(Tuple<int, double, std::string>(2, 2.5, "4")); | |
+ v.push_back(Tuple<int, double, std::string>(3, 3.5, "5")); | |
+ v.push_back(Tuple<int, double, std::string>(4, 4.5, "6")); | |
+ | |
+ tmp << "INSERT INTO Vectors VALUES (?,?,?)", use(v), now; | |
+ | |
+ Statement stmt = (tmp << "SELECT * FROM Vectors", now); | |
+ RecordSet rset(stmt); | |
+ assert(3 == rset.columnCount()); | |
+ assert(4 == rset.rowCount()); | |
+ | |
+ RecordSet rset2(rset); | |
+ assert(3 == rset2.columnCount()); | |
+ assert(4 == rset2.rowCount()); | |
+ | |
+ Int32 a = rset.value<Int32>(0, 2); | |
+ assert(3 == a); | |
+ | |
+ int c = rset2.value(0); | |
+ assert(1 == c); | |
+ | |
+ Int32 b = rset2.value<Int32>("InT0", 2); | |
+ assert(3 == b); | |
+ | |
+ double d = rset.value<double>(1, 0); | |
+ assert(1.5 == d); | |
+ | |
+ std::string s = rset.value<std::string>(2, 1); | |
+ assert("4" == s); | |
+ | |
+ typedef std::deque<Int32> IntDeq; | |
+ | |
+ const Column<IntDeq>& col = rset.column<IntDeq>(0); | |
+ assert(col[0] == 1); | |
+ | |
+ try { rset.column<IntDeq>(100); fail("must fail"); } | |
+ catch (RangeException&) {} | |
+ | |
+ const Column<IntDeq>& col1 = rset.column<IntDeq>(0); | |
+ assert("int0" == col1.name()); | |
+ Column<IntDeq>::Iterator it = col1.begin(); | |
+ Column<IntDeq>::Iterator itEnd = col1.end(); | |
+ int counter = 1; | |
+ for (; it != itEnd; ++it, ++counter) | |
+ assert(counter == *it); | |
+ | |
+ rset = (tmp << "SELECT COUNT(*) FROM Vectors", now); | |
+ s = rset.value<std::string>(0, 0); | |
+ assert("4" == s); | |
+ | |
+ stmt = (tmp << "DELETE FROM Vectors", now); | |
+ rset = stmt; | |
+ | |
+ try { rset.column<IntDeq>(0); fail("must fail"); } | |
+ catch (RangeException&) {} | |
+} | |
+ | |
+#endif // POCO_PTR_IS_64_BIT | |
+ | |
void SQLiteTest::testPrimaryKeyConstraint() | |
{ | |
@@ -2251,17 +2330,20 @@ void SQLiteTest::testAsync() | |
} | |
+#if defined(POCO_PTR_IS_64_BIT) && (POCO_PTR_IS_64_BIT == 1) | |
+ | |
void SQLiteTest::testAny() | |
{ | |
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db"); | |
tmp << "DROP TABLE IF EXISTS Anys", now; | |
- tmp << "CREATE TABLE Anys (int0 INTEGER, flt0 REAL, str0 VARCHAR)", now; | |
+ tmp << "CREATE TABLE Anys (int0 INTEGER32, flt0 REAL, str0 VARCHAR, int1 INTEGER)", now; | |
Any i = Int32(42); | |
Any f = double(42.5); | |
Any s = std::string("42"); | |
+ Any i64 = std::numeric_limits<Int64>::max(); | |
- tmp << "INSERT INTO Anys VALUES (?, ?, ?)", use(i), use(f), use(s), now; | |
+ tmp << "INSERT INTO Anys VALUES (?, ?, ?, ?)", use(i), use(f), use(s), use(i64), now; | |
int count = 0; | |
tmp << "SELECT COUNT(*) FROM Anys", into(count), now; | |
@@ -2270,12 +2352,43 @@ void SQLiteTest::testAny() | |
i = 0; | |
f = 0.0; | |
s = std::string(""); | |
- tmp << "SELECT * FROM Anys", into(i), into(f), into(s), now; | |
+ i64 = 0; | |
+ tmp << "SELECT * FROM Anys", into(i), into(f), into(s), into(i64), now; | |
assert (AnyCast<Int32>(i) == 42); | |
assert (AnyCast<double>(f) == 42.5); | |
- assert (AnyCast<std::string>(s) == "42"); | |
+ assert(AnyCast<std::string>(s) == "42"); | |
+ assert(AnyCast<Int64>(i64) == std::numeric_limits<Int64>::max()); | |
+} | |
+ | |
+#else // !POCO_PTR_IS_64_BIT | |
+ | |
+void SQLiteTest::testAny() | |
+{ | |
+ Session tmp(Poco::Data::SQLite::Connector::KEY, "dummy.db"); | |
+ tmp << "DROP TABLE IF EXISTS Anys", now; | |
+ tmp << "CREATE TABLE Anys (int0 INTEGER, flt0 REAL, str0 VARCHAR)", now; | |
+ | |
+ Any i = Int32(42); | |
+ Any f = double(42.5); | |
+ Any s = std::string("42"); | |
+ | |
+ tmp << "INSERT INTO Anys VALUES (?, ?, ?)", use(i), use(f), use(s), now; | |
+ | |
+ int count = 0; | |
+ tmp << "SELECT COUNT(*) FROM Anys", into(count), now; | |
+ assert(1 == count); | |
+ | |
+ i = 0; | |
+ f = 0.0; | |
+ s = std::string(""); | |
+ tmp << "SELECT * FROM Anys", into(i), into(f), into(s), now; | |
+ assert(AnyCast<Int32>(i) == 42); | |
+ assert(AnyCast<double>(f) == 42.5); | |
+ assert(AnyCast<std::string>(s) == "42"); | |
} | |
+#endif // POCO_PTR_IS_64_BIT | |
+ | |
void SQLiteTest::testDynamicAny() | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment