mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-03 21:06:25 +01:00
Dynamic::Var null support
This commit is contained in:
parent
ae45a2d311
commit
5658d4495f
@ -42,10 +42,11 @@
|
|||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Data/SQLite/Connector.h"
|
#include "Poco/Data/SQLite/Connector.h"
|
||||||
#include "Poco/Data/SQLite/Utility.h"
|
#include "Poco/Data/SQLite/Utility.h"
|
||||||
#include "Poco/Data/SQLite/SQLiteException.h"
|
#include "Poco/Dynamic/Var.h"
|
||||||
#include "Poco/Data/TypeHandler.h"
|
#include "Poco/Data/TypeHandler.h"
|
||||||
#include "Poco/Data/Nullable.h"
|
#include "Poco/Data/Nullable.h"
|
||||||
#include "Poco/Data/DataException.h"
|
#include "Poco/Data/DataException.h"
|
||||||
|
#include "Poco/Data/SQLite/SQLiteException.h"
|
||||||
#include "Poco/Tuple.h"
|
#include "Poco/Tuple.h"
|
||||||
#include "Poco/Any.h"
|
#include "Poco/Any.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
@ -93,6 +94,7 @@ using Poco::NullPointerException;
|
|||||||
using Poco::Data::SQLite::ConstraintViolationException;
|
using Poco::Data::SQLite::ConstraintViolationException;
|
||||||
using Poco::Data::SQLite::ParameterCountMismatchException;
|
using Poco::Data::SQLite::ParameterCountMismatchException;
|
||||||
using Poco::Int32;
|
using Poco::Int32;
|
||||||
|
using Poco::Dynamic::Var;
|
||||||
|
|
||||||
|
|
||||||
class Person
|
class Person
|
||||||
@ -1979,7 +1981,7 @@ void SQLiteTest::testNullable()
|
|||||||
assert (!s.isNull());
|
assert (!s.isNull());
|
||||||
assert (!d.isNull());
|
assert (!d.isNull());
|
||||||
|
|
||||||
ses << "SELECT i, r, s FROM NullableTest", into(i), into(f), into(s), into(d), now;
|
ses << "SELECT i, r, s, d FROM NullableTest", into(i), into(f), into(s), into(d), now;
|
||||||
|
|
||||||
assert (i.isNull());
|
assert (i.isNull());
|
||||||
assert (f.isNull());
|
assert (f.isNull());
|
||||||
@ -1993,6 +1995,23 @@ void SQLiteTest::testNullable()
|
|||||||
assert (rs.isNull("r"));
|
assert (rs.isNull("r"));
|
||||||
assert (rs.isNull("s"));
|
assert (rs.isNull("s"));
|
||||||
assert (rs.isNull("d"));
|
assert (rs.isNull("d"));
|
||||||
|
|
||||||
|
Var di = 1;
|
||||||
|
Var df = 1.5;
|
||||||
|
Var ds = "abc";
|
||||||
|
Var dd = DateTime();
|
||||||
|
|
||||||
|
assert (!di.isEmpty());
|
||||||
|
assert (!df.isEmpty());
|
||||||
|
assert (!ds.isEmpty());
|
||||||
|
assert (!dd.isEmpty());
|
||||||
|
|
||||||
|
ses << "SELECT i, r, s, d FROM NullableTest", into(di), into(df), into(ds), into(dd), now;
|
||||||
|
|
||||||
|
assert (di.isEmpty());
|
||||||
|
assert (df.isEmpty());
|
||||||
|
assert (ds.isEmpty());
|
||||||
|
assert (dd.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -505,6 +505,8 @@ void AbstractBinder::bind(std::size_t pos, const Poco::Dynamic::Var& val, Direct
|
|||||||
bind(pos, val.extract<Time>(), dir);
|
bind(pos, val.extract<Time>(), dir);
|
||||||
else if(type == typeid(BLOB))
|
else if(type == typeid(BLOB))
|
||||||
bind(pos, val.extract<BLOB>(), dir);
|
bind(pos, val.extract<BLOB>(), dir);
|
||||||
|
else if(type == typeid(void))
|
||||||
|
bind(pos, Keywords::null, dir);
|
||||||
#ifndef POCO_LONG_IS_64_BIT
|
#ifndef POCO_LONG_IS_64_BIT
|
||||||
else if(type == typeid(long))
|
else if(type == typeid(long))
|
||||||
bind(pos, val.extract<long>(), dir);
|
bind(pos, val.extract<long>(), dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user