mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
fixed GH #1236: Remove Poco::Data::Row::checkEmpty() as it prevents Row from being used with all NULL rows
This commit is contained in:
@@ -218,10 +218,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void init(const SortMapPtr& pSortMap, const RowFormatter::Ptr& pFormatter);
|
void init(const SortMapPtr& pSortMap, const RowFormatter::Ptr& pFormatter);
|
||||||
|
|
||||||
void checkEmpty(std::size_t pos, const Poco::Dynamic::Var& val);
|
|
||||||
/// Check if row contains only empty values and throws IllegalStateException
|
|
||||||
/// if that is the case.
|
|
||||||
|
|
||||||
ValueVec& values();
|
ValueVec& values();
|
||||||
/// Returns the reference to values vector.
|
/// Returns the reference to values vector.
|
||||||
|
|
||||||
|
|||||||
@@ -109,28 +109,10 @@ std::size_t Row::getPosition(const std::string& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Row::checkEmpty(std::size_t pos, const Poco::Dynamic::Var& val)
|
|
||||||
{
|
|
||||||
bool empty = true;
|
|
||||||
SortMap::const_iterator it = _pSortMap->begin();
|
|
||||||
SortMap::const_iterator end = _pSortMap->end();
|
|
||||||
for (std::size_t cnt = 0; it != end; ++it, ++cnt)
|
|
||||||
{
|
|
||||||
if (cnt != pos)
|
|
||||||
empty = empty && _values[it->get<0>()].isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty && val.isEmpty())
|
|
||||||
throw IllegalStateException("All values are empty.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Row::addSortField(std::size_t pos)
|
void Row::addSortField(std::size_t pos)
|
||||||
{
|
{
|
||||||
poco_assert (pos <= _values.size());
|
poco_assert (pos <= _values.size());
|
||||||
|
|
||||||
checkEmpty(std::numeric_limits<std::size_t>::max(), _values[pos]);
|
|
||||||
|
|
||||||
SortMap::iterator it = _pSortMap->begin();
|
SortMap::iterator it = _pSortMap->begin();
|
||||||
SortMap::iterator end = _pSortMap->end();
|
SortMap::iterator end = _pSortMap->end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
@@ -177,8 +159,6 @@ void Row::addSortField(const std::string& name)
|
|||||||
|
|
||||||
void Row::removeSortField(std::size_t pos)
|
void Row::removeSortField(std::size_t pos)
|
||||||
{
|
{
|
||||||
checkEmpty(pos, Poco::Dynamic::Var());
|
|
||||||
|
|
||||||
SortMap::iterator it = _pSortMap->begin();
|
SortMap::iterator it = _pSortMap->begin();
|
||||||
SortMap::iterator end = _pSortMap->end();
|
SortMap::iterator end = _pSortMap->end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
|
|||||||
@@ -953,18 +953,6 @@ void DataTest::testRow()
|
|||||||
fail ("must fail");
|
fail ("must fail");
|
||||||
}catch (NotFoundException&) {}
|
}catch (NotFoundException&) {}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
row4.set("field1", Var());
|
|
||||||
row4.addSortField(1);
|
|
||||||
row4.removeSortField(0);
|
|
||||||
fail ("must fail - field 1 is empty");
|
|
||||||
}
|
|
||||||
catch (IllegalStateException&)
|
|
||||||
{
|
|
||||||
row4.removeSortField(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
row4.set("field0", 0);
|
row4.set("field0", 0);
|
||||||
row4.set("field1", 1);
|
row4.set("field1", 1);
|
||||||
row4.set("field2", 2);
|
row4.set("field2", 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user