mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-23 23:16:39 +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:
parent
d82b6b3975
commit
ed23f24639
@ -218,10 +218,6 @@ public:
|
||||
private:
|
||||
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();
|
||||
/// 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)
|
||||
{
|
||||
poco_assert (pos <= _values.size());
|
||||
|
||||
checkEmpty(std::numeric_limits<std::size_t>::max(), _values[pos]);
|
||||
|
||||
SortMap::iterator it = _pSortMap->begin();
|
||||
SortMap::iterator end = _pSortMap->end();
|
||||
for (; it != end; ++it)
|
||||
@ -177,8 +159,6 @@ void Row::addSortField(const std::string& name)
|
||||
|
||||
void Row::removeSortField(std::size_t pos)
|
||||
{
|
||||
checkEmpty(pos, Poco::Dynamic::Var());
|
||||
|
||||
SortMap::iterator it = _pSortMap->begin();
|
||||
SortMap::iterator end = _pSortMap->end();
|
||||
for (; it != end; ++it)
|
||||
|
@ -953,18 +953,6 @@ void DataTest::testRow()
|
||||
fail ("must fail");
|
||||
}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("field1", 1);
|
||||
row4.set("field2", 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user