diff --git a/Data/SQLite/src/Utility.cpp b/Data/SQLite/src/Utility.cpp index cc9797480..e887813bc 100644 --- a/Data/SQLite/src/Utility.cpp +++ b/Data/SQLite/src/Utility.cpp @@ -92,7 +92,7 @@ void Utility::initializeDefaultTypes() _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 d3a07e2bc..ec0b1e9ef 100644 --- a/Data/SQLite/testsuite/src/SQLiteTest.cpp +++ b/Data/SQLite/testsuite/src/SQLiteTest.cpp @@ -85,6 +85,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; @@ -1911,6 +1912,109 @@ void SQLiteTest::testDateTime() assert (rt == t); } +#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 INTEGER32, flt0 REAL, str0 VARCHAR, int1 INTEGER)", now; + + std::vector > v; + v.push_back(Tuple(1, 1.5, "3", 1)); + v.push_back(Tuple(2, 2.5, "4", 2)); + v.push_back(Tuple(3, 3.5, "5", 3)); + v.push_back(Tuple(4, 4.5, "6", Int64(std::numeric_limits::max()))); + + tmp << "INSERT INTO Vectors VALUES (?,?,?,?)", use(v), now; + + Statement stmt = (tmp << "SELECT * FROM Vectors", now); + RecordSet rset(stmt); + assert (4 == rset.columnCount()); + assert (4 == rset.rowCount()); + + RecordSet rset2(rset); + assert (4 == rset2.columnCount()); + assert (4 == rset2.rowCount()); + + Int32 a = rset.value(0,2); + assert (3 == a); + + Int64 x = rset.value(3, 2); + assert(3 == x); + + x = rset.value(3, 3); + assert(std::numeric_limits::max() == x); + + int c = rset2.value(0); + assert (1 == c); + + Int32 b = rset2.value("InT0",2); + assert (3 == b); + + double d = rset.value(1,0); + assert (1.5 == d); + + std::string s = rset.value(2,1); + assert ("4" == s); + + typedef std::deque IntDeq; + + const Column& col = rset.column(0); + assert (col[0] == 1); + + try { rset.column(100); fail ("must fail"); } + catch (RangeException&) { } + + const Column& col1 = rset.column(0); + assert ("int0" == col1.name()); + Column::Iterator it = col1.begin(); + Column::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(0,0); + assert ("4" == s); + + stmt = (tmp << "DELETE FROM Vectors", now); + rset = stmt; + + try { rset.column(0); fail ("must fail"); } + catch (RangeException&) { } +} + + +void SQLiteTest::testAny() +{ + Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db"); + tmp << "DROP TABLE IF EXISTS Anys", 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::max(); + + 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; + assert (1 == count); + + i = 0; + f = 0.0; + s = std::string(""); + i64 = 0; + tmp << "SELECT * FROM Anys", into(i), into(f), into(s), into(i64), now; + assert (AnyCast(i) == 42); + assert (AnyCast(f) == 42.5); + assert (AnyCast(s) == "42"); + assert (AnyCast(i64) == std::numeric_limits::max()); +} + +#else // !POCO_PTR_IS_64_BIT void SQLiteTest::testInternalExtraction() { @@ -1978,6 +2082,34 @@ void SQLiteTest::testInternalExtraction() } +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(i) == 42); + assert (AnyCast(f) == 42.5); + assert (AnyCast(s) == "42"); +} + +#endif // POCO_PTR_IS_64_BIT + + void SQLiteTest::testPrimaryKeyConstraint() { Session ses (Poco::Data::SQLite::Connector::KEY, "dummy.db"); @@ -2261,32 +2393,6 @@ void SQLiteTest::testAsync() } -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(i) == 42); - assert (AnyCast(f) == 42.5); - assert (AnyCast(s) == "42"); -} - - void SQLiteTest::testDynamicAny() { Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");