mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-24 22:29:47 +01:00
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:
@@ -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
|
||||
|
||||
@@ -59,7 +59,6 @@ MetaColumn::MetaColumn(std::size_t position,
|
||||
_type(type),
|
||||
_nullable(nullable)
|
||||
{
|
||||
poco_assert(position >= 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user