Commit b21925d7 authored by msobczak's avatar msobczak

Fix for vector truncation when no data fetched.

parent 9c8ed04d
......@@ -364,6 +364,7 @@ bool statement_impl::fetch()
{
if (fetchSize_ == 0)
{
truncate_intos();
session_.set_got_data(false);
return false;
}
......@@ -415,6 +416,7 @@ bool statement_impl::fetch()
}
else
{
truncate_intos();
gotData = false;
}
}
......@@ -501,6 +503,15 @@ bool statement_impl::resize_intos(std::size_t upperBound)
return rows > 0 ? true : false;
}
void statement_impl::truncate_intos()
{
std::size_t const isize = intos_.size();
for (std::size_t i = 0; i != isize; ++i)
{
intos_[i]->resize(0);
}
}
void statement_impl::pre_fetch()
{
std::size_t const isize = intos_.size();
......
......@@ -109,6 +109,7 @@ private:
void post_fetch(bool gotData, bool calledFromFetch);
void post_use(bool gotData);
bool resize_intos(std::size_t upperBound = 0);
void truncate_intos();
soci::details::statement_backend * backEnd_;
......
......@@ -1043,7 +1043,11 @@ void test4()
// for even more convenience, fetch should not fail
// but just report end of rowset
// (and vectors should be truncated)
vals.resize(1);
inds.resize(1);
gotData = st.fetch();
assert(gotData == false);
assert(vals.empty());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment