diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-08 11:56:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-08 11:56:00 +0200 |
commit | 46b2db37445b97cd3dbb8acd4f417e0851a30e4f (patch) | |
tree | 4344ebf0ed702b7a3148b8d6c695319982e9fb52 | |
parent | ecfffbc56def1cfc87d34a70c0fb9f9241459e54 (diff) |
More query result size() fixes
-rw-r--r-- | odb/mysql/no-id-object-result.txx | 10 | ||||
-rw-r--r-- | odb/mysql/polymorphic-object-result.txx | 10 | ||||
-rw-r--r-- | odb/mysql/simple-object-result.txx | 10 | ||||
-rw-r--r-- | odb/mysql/view-result.txx | 10 |
4 files changed, 24 insertions, 16 deletions
diff --git a/odb/mysql/no-id-object-result.txx b/odb/mysql/no-id-object-result.txx index 6418987..0f996d1 100644 --- a/odb/mysql/no-id-object-result.txx +++ b/odb/mysql/no-id-object-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 object is loaded in between iteration, the @@ -137,9 +140,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; } } @@ -157,9 +161,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. } } } diff --git a/odb/mysql/polymorphic-object-result.txx b/odb/mysql/polymorphic-object-result.txx index 5fe5b48..1e341ff 100644 --- a/odb/mysql/polymorphic-object-result.txx +++ b/odb/mysql/polymorphic-object-result.txx @@ -194,6 +194,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 object is loaded in between iteration, the @@ -322,9 +325,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; } } @@ -342,9 +346,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. } } } diff --git a/odb/mysql/simple-object-result.txx b/odb/mysql/simple-object-result.txx index f67827c..b5a5f3a 100644 --- a/odb/mysql/simple-object-result.txx +++ b/odb/mysql/simple-object-result.txx @@ -102,6 +102,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 object is loaded in between iteration, the @@ -193,9 +196,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; } } @@ -213,9 +217,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. } } } 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. } } } |