diff --git a/drivers/mysql/include_private/orm/drivers/mysql/mysqlresult_p.hpp b/drivers/mysql/include_private/orm/drivers/mysql/mysqlresult_p.hpp index 52ee620c7..8198c18d9 100644 --- a/drivers/mysql/include_private/orm/drivers/mysql/mysqlresult_p.hpp +++ b/drivers/mysql/include_private/orm/drivers/mysql/mysqlresult_p.hpp @@ -89,7 +89,7 @@ namespace Orm::Drivers::MySql QVariant getValueForPrepared(ResultFieldsSizeType index) const; /*! Throw an exception if an index for result fields vector is out of bounds. */ - void throwIfBadResultFieldsIndex(ResultFieldsSizeType index) const; + void throwIfBadResultFieldsIndex(size_type index) const; /* Data members */ /* Common for both */ diff --git a/drivers/mysql/src/orm/drivers/mysql/mysqlresult.cpp b/drivers/mysql/src/orm/drivers/mysql/mysqlresult.cpp index 7780239cf..06ca4a3b8 100644 --- a/drivers/mysql/src/orm/drivers/mysql/mysqlresult.cpp +++ b/drivers/mysql/src/orm/drivers/mysql/mysqlresult.cpp @@ -419,10 +419,10 @@ QVariant MySqlResult::data(const size_type index) const { Q_D(const MySqlResult); - const auto idx = static_cast(index); - // Throw an exception if an index for result fields vector is out of bounds - d->throwIfBadResultFieldsIndex(idx); + d->throwIfBadResultFieldsIndex(index); + + const auto idx = static_cast(index); if (d->preparedQuery) return d->getValueForPrepared(idx); @@ -434,10 +434,10 @@ bool MySqlResult::isNull(const size_type index) const { Q_D(const MySqlResult); - const auto idx = static_cast(index); - // Throw an exception if an index for result fields vector is out of bounds - d->throwIfBadResultFieldsIndex(idx); + d->throwIfBadResultFieldsIndex(index); + + const auto idx = static_cast(index); /* MyField::isNull is populated for prepared statements only. The row/result set/data must be fetched first to obtain the correct result. ❗ */ diff --git a/drivers/mysql/src/orm/drivers/mysql/mysqlresult_p.cpp b/drivers/mysql/src/orm/drivers/mysql/mysqlresult_p.cpp index 386854f31..6b18652b4 100644 --- a/drivers/mysql/src/orm/drivers/mysql/mysqlresult_p.cpp +++ b/drivers/mysql/src/orm/drivers/mysql/mysqlresult_p.cpp @@ -368,12 +368,12 @@ QVariant MySqlResultPrivate::getValueForPrepared(const ResultFieldsSizeType inde } void -MySqlResultPrivate::throwIfBadResultFieldsIndex(const ResultFieldsSizeType index) const +MySqlResultPrivate::throwIfBadResultFieldsIndex(const size_type index) const { const auto fieldsCount = resultFields.size(); // Nothing to do - if (index >= 0 || index < fieldsCount) + if (index >= 0 || index < static_cast(fieldsCount)) return; throw Exceptions::OutOfRangeError(