diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-28 14:42:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-28 14:42:23 +0200 |
commit | 5303dd088f25ecbd5cf2b3bd423f977874223fae (patch) | |
tree | ff85ce7339c8d0838bff210dba031cbbbfbcebf3 /odb/pgsql/simple-object-result.txx | |
parent | f8a9600d83a7ebaa0321a59d1b2ebb53671f665d (diff) |
Make sure size() can still be called once we reached the end of result set
Diffstat (limited to 'odb/pgsql/simple-object-result.txx')
-rw-r--r-- | odb/pgsql/simple-object-result.txx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/odb/pgsql/simple-object-result.txx b/odb/pgsql/simple-object-result.txx index f7b2e1c..81b5f73 100644 --- a/odb/pgsql/simple-object-result.txx +++ b/odb/pgsql/simple-object-result.txx @@ -27,7 +27,8 @@ namespace odb statements_type& statements) : base_type (statements.connection ().database ()), statement_ (statement), - statements_ (statements) + statements_ (statements), + count_ (0) { } @@ -84,7 +85,9 @@ namespace odb { this->current (pointer_type ()); - if (!statement_->next ()) + if (statement_->next ()) + count_++; + else { statement_->free_result (); this->end_ = true; @@ -136,7 +139,7 @@ namespace odb std::size_t object_result_impl<T>:: size () { - return statement_->result_size (); + return this->end_ ? count_ : statement_->result_size (); } } } |