diff options
Diffstat (limited to 'odb/mysql/polymorphic-object-result.txx')
-rw-r--r-- | odb/mysql/polymorphic-object-result.txx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/odb/mysql/polymorphic-object-result.txx b/odb/mysql/polymorphic-object-result.txx index 221060b..5fe5b48 100644 --- a/odb/mysql/polymorphic-object-result.txx +++ b/odb/mysql/polymorphic-object-result.txx @@ -318,7 +318,7 @@ namespace odb void polymorphic_object_result_impl<T>:: cache () { - if (!statement_->cached ()) + if (!this->end_ && !statement_->cached ()) { statement_->cache (); @@ -334,10 +334,17 @@ namespace odb std::size_t polymorphic_object_result_impl<T>:: size () { - if (!statement_->cached ()) - throw result_not_cached (); + if (!this->end_) + { + if (!statement_->cached ()) + throw result_not_cached (); - return statement_->result_size (); + return statement_->result_size (); + } + else + // If count is not zero, then it is one past the result size. + // + return count_ == 0 ? 0 : count_ - 1; } } } |