Changes related to following tracker items:

[2025916] ODBC binds empty string as null?
[2000408] DynamicAny non-initialized state support
[1981130] pointless comparison of unsigned integer with zero

and some refactoring.

Warning: only tested on Windows.
This commit is contained in:
Aleksandar Fabijanic
2008-07-29 20:11:38 +00:00
parent 3e65280dc1
commit fc5a503593
21 changed files with 435 additions and 106 deletions

View File

@@ -47,7 +47,9 @@ AbstractExtraction::AbstractExtraction(Poco::UInt32 limit,
_pExtractor(0),
_limit(limit),
_position(position),
_bulk(bulk)
_bulk(bulk),
_emptyStringIsNull(false),
_forceEmptyString(false)
{
}
@@ -57,4 +59,16 @@ AbstractExtraction::~AbstractExtraction()
}
template <>
bool AbstractExtraction::isValueNull(const std::string& str, bool deflt)
{
if (getForceEmptyString()) return false;
if (getEmptyStringIsNull() && str.empty())
return true;
return deflt;
}
} } // namespace Poco::Data

View File

@@ -59,7 +59,6 @@ MetaColumn::MetaColumn(std::size_t position,
_type(type),
_nullable(nullable)
{
poco_assert(position >= 0);
}

View File

@@ -93,6 +93,8 @@ RecordSet::~RecordSet()
DynamicAny RecordSet::value(std::size_t col, std::size_t row) const
{
if (isNull(col, row)) return DynamicAny();
switch (columnType(col))
{
case MetaColumn::FDT_BOOL: return value<bool>(col, row);
@@ -119,6 +121,8 @@ DynamicAny RecordSet::value(std::size_t col, std::size_t row) const
DynamicAny RecordSet::value(const std::string& name, std::size_t row) const
{
if (isNull(metaColumn(name).position(), row)) return DynamicAny();
switch (columnType(name))
{
case MetaColumn::FDT_BOOL: return value<bool>(name, row);

View File

@@ -364,6 +364,12 @@ void StatementImpl::addExtract(AbstractExtraction* pExtraction)
if (pos >= _extractors.size())
_extractors.resize(pos + 1);
pExtraction->setEmptyStringIsNull(
_rSession.getFeature("emptyStringIsNull"));
pExtraction->setForceEmptyString(
_rSession.getFeature("forceEmptyString"));
_extractors[pos].push_back(pExtraction);
}