diff --git a/include/orm/ormtypes.hpp b/include/orm/ormtypes.hpp index e320f297e..02ea0cee8 100644 --- a/include/orm/ormtypes.hpp +++ b/include/orm/ormtypes.hpp @@ -275,8 +275,10 @@ namespace Query TINYORM_END_COMMON_NAMESPACE #ifdef TINYORM_COMMON_NAMESPACE +// NOLINTNEXTLINE(performance-no-int-to-ptr) Q_DECLARE_METATYPE(TINYORM_COMMON_NAMESPACE::Orm::WhereConditionItem) #else +// NOLINTNEXTLINE(performance-no-int-to-ptr) Q_DECLARE_METATYPE(Orm::WhereConditionItem) #endif diff --git a/include/orm/query/expression.hpp b/include/orm/query/expression.hpp index c2da9beec..1dbcf9156 100644 --- a/include/orm/query/expression.hpp +++ b/include/orm/query/expression.hpp @@ -64,8 +64,10 @@ namespace Orm::Query TINYORM_END_COMMON_NAMESPACE #ifdef TINYORM_COMMON_NAMESPACE +// NOLINTNEXTLINE(performance-no-int-to-ptr) Q_DECLARE_METATYPE(TINYORM_COMMON_NAMESPACE::Orm::Query::Expression) #else +// NOLINTNEXTLINE(performance-no-int-to-ptr) Q_DECLARE_METATYPE(Orm::Query::Expression) #endif diff --git a/include/orm/tiny/model.hpp b/include/orm/tiny/model.hpp index c5bf0b8cc..02639e597 100644 --- a/include/orm/tiny/model.hpp +++ b/include/orm/tiny/model.hpp @@ -148,12 +148,12 @@ namespace Relations { /*! Model's copy constructor. */ inline Model(const Model &) = default; /*! Model's move constructor. */ - inline Model(Model &&) = default; + inline Model(Model &&) noexcept = default; /*! Model's copy assignment operator. */ inline Model &operator=(const Model &) = default; /*! Model's move assignment operator. */ - inline Model &operator=(Model &&) = default; + inline Model &operator=(Model &&) noexcept = default; /*! Create a new TinORM model instance from attributes (converting constructor). */ @@ -233,7 +233,7 @@ namespace Relations { std::unique_ptr> newQueryWithoutRelationships(); /*! Create a new Tiny query builder for the model. */ std::unique_ptr> - newTinyBuilder(const QSharedPointer query); + newTinyBuilder(const QSharedPointer &query); /*! Create a new model instance that is existing. */ Derived newFromBuilder(const QVector &attributes = {}, @@ -1462,10 +1462,13 @@ namespace Relations { std::unique_ptr> Model::newModelQuery() { + // Ownership of the QSharedPointer + const auto query = newBaseQueryBuilder(); + /* Model is passed to the TinyBuilder ctor, because of that setModel() isn't used here. Can't be const because of passed non-const model to the TinyBuilder. */ - return newTinyBuilder(newBaseQueryBuilder()); + return newTinyBuilder(query); } template @@ -1478,7 +1481,7 @@ namespace Relations { template std::unique_ptr> Model::newTinyBuilder( - const QSharedPointer query) + const QSharedPointer &query) { return std::make_unique>(query, model()); } @@ -1966,7 +1969,7 @@ namespace Relations { /* Finally, we will just assume this date is in the format used by default on the database connection and use that format to create the QDateTime object that is returned back out to the developers after we convert it here. */ - if (const auto date = QDateTime::fromString(value.value(), format); + if (auto date = QDateTime::fromString(value.value(), format); date.isValid() ) return date; @@ -2926,7 +2929,7 @@ namespace Relations { this->createBelongsToManyRelatedTableStore().visit(relation); // NRVO kicks in - const auto relatedTable = this->belongsToManyRelatedTableStore().m_result; + auto relatedTable = this->belongsToManyRelatedTableStore().m_result; // Releases the ownership and destroy the top relation store on the stack this->resetRelationStore(); diff --git a/include/orm/tiny/tinybuilder.hpp b/include/orm/tiny/tinybuilder.hpp index 8bf16045c..144752764 100644 --- a/include/orm/tiny/tinybuilder.hpp +++ b/include/orm/tiny/tinybuilder.hpp @@ -32,7 +32,7 @@ namespace Orm::Tiny public: /*! Constructor. */ - Builder(const QSharedPointer query, Model &model); + Builder(const QSharedPointer &query, Model &model); /*! Get the SQL representation of the query. */ QString toSql() const; @@ -209,7 +209,7 @@ namespace Orm::Tiny }; template - Builder::Builder(const QSharedPointer query, + Builder::Builder(const QSharedPointer &query, Model &model) : m_query(query) , m_model(model)