From 46b2db37445b97cd3dbb8acd4f417e0851a30e4f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Oct 2012 11:56:00 +0200 Subject: More query result size() fixes --- odb/mysql/view-result.txx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'odb/mysql/view-result.txx') diff --git a/odb/mysql/view-result.txx b/odb/mysql/view-result.txx index cc5178e..bc56ebb 100644 --- a/odb/mysql/view-result.txx +++ b/odb/mysql/view-result.txx @@ -51,6 +51,9 @@ namespace odb { this->current (pointer_type ()); + if (this->end_) + return; + // If we are cached, simply increment the position and // postpone the actual row fetching until later. This way // if the same view is loaded in between iteration, the @@ -136,9 +139,10 @@ namespace odb { statement_->cache (); - if (count_ >= statement_->result_size ()) + if (count_ == statement_->result_size ()) { statement_->free_result (); + count_++; // One past the result size. this->end_ = true; } } @@ -156,9 +160,7 @@ namespace odb return statement_->result_size (); } else - // If count is not zero, then it is one past the result size. - // - return count_ == 0 ? 0 : count_ - 1; + return count_ - 1; // One past the result size. } } } -- cgit v1.1