From 5303dd088f25ecbd5cf2b3bd423f977874223fae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Sep 2012 14:42:23 +0200 Subject: Make sure size() can still be called once we reached the end of result set --- odb/pgsql/polymorphic-object-result.txx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'odb/pgsql/polymorphic-object-result.txx') diff --git a/odb/pgsql/polymorphic-object-result.txx b/odb/pgsql/polymorphic-object-result.txx index 9d50427..02a71a0 100644 --- a/odb/pgsql/polymorphic-object-result.txx +++ b/odb/pgsql/polymorphic-object-result.txx @@ -28,7 +28,8 @@ namespace odb statements_type& sts) : base_type (sts.connection ().database ()), statement_ (st), - statements_ (sts) + statements_ (sts), + count_ (0) { } @@ -167,7 +168,9 @@ namespace odb { this->current (pointer_type ()); - if (!statement_->next ()) + if (statement_->next ()) + count_++; + else { statement_->free_result (); this->end_ = true; @@ -259,7 +262,7 @@ namespace odb std::size_t polymorphic_object_result_impl:: size () { - return statement_->result_size (); + return this->end_ ? count_ : statement_->result_size (); } } } -- cgit v1.1