mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-21 02:00:33 +01:00
parent
4b4adb4459
commit
5d69bae19f
@ -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));
|
||||
|
@ -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<Tuple<int, double, std::string, Int64> > v;
|
||||
v.push_back(Tuple<int, double, std::string, Int64>(1, 1.5, "3", 1));
|
||||
v.push_back(Tuple<int, double, std::string, Int64>(2, 2.5, "4", 2));
|
||||
v.push_back(Tuple<int, double, std::string, Int64>(3, 3.5, "5", 3));
|
||||
v.push_back(Tuple<int, double, std::string, Int64>(4, 4.5, "6", Int64(std::numeric_limits<Int64>::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<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);
|
||||
|
||||
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&) { }
|
||||
}
|
||||
|
||||
|
||||
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<Int64>::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<Int32>(i) == 42);
|
||||
assert (AnyCast<double>(f) == 42.5);
|
||||
assert (AnyCast<std::string>(s) == "42");
|
||||
assert (AnyCast<Int64>(i64) == std::numeric_limits<Int64>::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<Int32>(i) == 42);
|
||||
assert (AnyCast<double>(f) == 42.5);
|
||||
assert (AnyCast<std::string>(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<Int32>(i) == 42);
|
||||
assert (AnyCast<double>(f) == 42.5);
|
||||
assert (AnyCast<std::string>(s) == "42");
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testDynamicAny()
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
|
Loading…
x
Reference in New Issue
Block a user