mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-24 07:21:30 +01:00
fixed GH# #1203: Poco::Data::RecordSet should be reusable
This commit is contained in:
parent
6572db8df0
commit
58751caca0
@ -315,6 +315,13 @@ public:
|
|||||||
/// Returns true if there is at least one row in the RecordSet,
|
/// Returns true if there is at least one row in the RecordSet,
|
||||||
/// false otherwise.
|
/// false otherwise.
|
||||||
|
|
||||||
|
void reset(const Statement& stmt);
|
||||||
|
/// Resets the RecordSet and assigns a new statement.
|
||||||
|
/// Should be called after the given statement has been reset,
|
||||||
|
/// assigned a new SQL statement, and executed.
|
||||||
|
///
|
||||||
|
/// Does not remove the associated RowFilter or RowFormatter.
|
||||||
|
|
||||||
Poco::Dynamic::Var value(const std::string& name);
|
Poco::Dynamic::Var value(const std::string& name);
|
||||||
/// Returns the value in the named column of the current row.
|
/// Returns the value in the named column of the current row.
|
||||||
|
|
||||||
@ -525,8 +532,8 @@ inline std::size_t RecordSet::columnCount() const
|
|||||||
|
|
||||||
inline Statement& RecordSet::operator = (const Statement& stmt)
|
inline Statement& RecordSet::operator = (const Statement& stmt)
|
||||||
{
|
{
|
||||||
_currentRow = 0;
|
reset(stmt);
|
||||||
return Statement::operator = (stmt);
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -638,37 +645,6 @@ inline void RecordSet::formatNames() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
namespace Keywords {
|
|
||||||
|
|
||||||
|
|
||||||
inline const std::string& select(const std::string& str)
|
|
||||||
{
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const RecordSet& from(const RecordSet& rs)
|
|
||||||
{
|
|
||||||
return rs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline RecordSet from(const Statement& stmt)
|
|
||||||
{
|
|
||||||
return RecordSet(stmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const std::string& where(const std::string& str)
|
|
||||||
{
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Keywords
|
|
||||||
*/
|
|
||||||
|
|
||||||
} } // namespace Poco::Data
|
} } // namespace Poco::Data
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ RecordSet::RecordSet(const RecordSet& other):
|
|||||||
_pFilter(other._pFilter),
|
_pFilter(other._pFilter),
|
||||||
_totalRowCount(other._totalRowCount)
|
_totalRowCount(other._totalRowCount)
|
||||||
{
|
{
|
||||||
|
if(_pFilter) _pFilter->duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ RecordSet::~RecordSet()
|
|||||||
{
|
{
|
||||||
delete _pBegin;
|
delete _pBegin;
|
||||||
delete _pEnd;
|
delete _pEnd;
|
||||||
if(_pFilter) _pFilter->release();
|
if (_pFilter) _pFilter->release();
|
||||||
|
|
||||||
RowMap::iterator it = _rowMap.begin();
|
RowMap::iterator it = _rowMap.begin();
|
||||||
RowMap::iterator end = _rowMap.end();
|
RowMap::iterator end = _rowMap.end();
|
||||||
@ -92,6 +93,22 @@ RecordSet::~RecordSet()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RecordSet::reset(const Statement& stmt)
|
||||||
|
{
|
||||||
|
delete _pBegin;
|
||||||
|
_pBegin = 0;
|
||||||
|
delete _pEnd;
|
||||||
|
_pEnd = 0;
|
||||||
|
_currentRow = 0;
|
||||||
|
_totalRowCount = UNKNOWN_TOTAL_ROW_COUNT;
|
||||||
|
|
||||||
|
Statement::operator = (stmt);
|
||||||
|
|
||||||
|
_pBegin = new RowIterator(this, 0 == rowsExtracted());
|
||||||
|
_pEnd = new RowIterator(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
|
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
|
||||||
{
|
{
|
||||||
if (useFilter && isFiltered() && !isAllowed(row))
|
if (useFilter && isFiltered() && !isAllowed(row))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user