diff --git a/include/orm/databaseconnection.hpp b/include/orm/databaseconnection.hpp index bb536ad5c..4047cc4b3 100644 --- a/include/orm/databaseconnection.hpp +++ b/include/orm/databaseconnection.hpp @@ -81,7 +81,7 @@ namespace SchemaNs inline ~DatabaseConnection() override = 0; /*! Begin a fluent query against a database table. */ - QSharedPointer + std::shared_ptr table(const QString &table, const QString &as = ""); /*! Get the table prefix for the connection. */ @@ -92,7 +92,7 @@ namespace SchemaNs BaseGrammar &withTablePrefix(BaseGrammar &grammar) const; /*! Get a new query builder instance. */ - QSharedPointer query(); + std::shared_ptr query(); /*! Get a new raw query expression. */ inline Query::Expression raw(const QVariant &value) const; diff --git a/include/orm/databasemanager.hpp b/include/orm/databasemanager.hpp index a547dd308..61291497e 100644 --- a/include/orm/databasemanager.hpp +++ b/include/orm/databasemanager.hpp @@ -50,15 +50,15 @@ namespace Query /* Proxy methods to the DatabaseConnection */ /*! Begin a fluent query against a database table for the connection. */ - QSharedPointer + std::shared_ptr table(const QString &table, const QString &connection = ""); /*! Begin a fluent query against a database table for the connection. */ - QSharedPointer + std::shared_ptr tableAs(const QString &table, const QString &as = "", const QString &connection = ""); /*! Get a new query builder instance for the connection. */ - QSharedPointer query(const QString &connection = ""); + std::shared_ptr query(const QString &connection = ""); /*! Get a new QSqlQuery instance for the connection. */ QSqlQuery qtQuery(const QString &connection = ""); diff --git a/include/orm/db.hpp b/include/orm/db.hpp index 34226261c..c7196988f 100644 --- a/include/orm/db.hpp +++ b/include/orm/db.hpp @@ -100,15 +100,15 @@ namespace Orm /* Proxy methods to the DatabaseConnection */ /*! Begin a fluent query against a database table for the connection. */ - static QSharedPointer + static std::shared_ptr table(const QString &table, const QString &connection = ""); /*! Begin a fluent query against a database table for the connection. */ - static QSharedPointer + static std::shared_ptr tableAs(const QString &table, const QString &as = "", const QString &connection = ""); /*! Get a new query builder instance for the connection. */ - static QSharedPointer query(const QString &connection = ""); + static std::shared_ptr query(const QString &connection = ""); /*! Get a new QSqlQuery instance for the connection. */ static QSqlQuery qtQuery(const QString &connection = ""); diff --git a/include/orm/ormtypes.hpp b/include/orm/ormtypes.hpp index df146b26a..12122c4ef 100644 --- a/include/orm/ormtypes.hpp +++ b/include/orm/ormtypes.hpp @@ -5,10 +5,10 @@ #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER -#include #include #include +#include #include #include "orm/constants.hpp" @@ -83,15 +83,15 @@ namespace Query /*! Where clause item, primarily used in grammars to build sql query. */ struct WhereConditionItem { - Column column {}; - QVariant value {}; - QString comparison {Orm::Constants::EQ}; - QString condition {Orm::Constants::AND}; - WhereType type {WhereType::UNDEFINED}; - QSharedPointer nestedQuery {nullptr}; - QVector values {}; - Column columnTwo {}; - QString sql {}; + Column column {}; + QVariant value {}; + QString comparison {Orm::Constants::EQ}; + QString condition {Orm::Constants::AND}; + WhereType type {WhereType::UNDEFINED}; + std::shared_ptr nestedQuery {nullptr}; + QVector values {}; + Column columnTwo {}; + QString sql {}; }; /*! Supported having types. */ diff --git a/include/orm/query/joinclause.hpp b/include/orm/query/joinclause.hpp index ad710cd16..834a1e02e 100644 --- a/include/orm/query/joinclause.hpp +++ b/include/orm/query/joinclause.hpp @@ -55,11 +55,11 @@ namespace Orm::Query getTable() const; /*! Get a new instance of the join clause builder. */ - QSharedPointer newQuery() const final; + std::shared_ptr newQuery() const final; protected: /*! Create a new query instance for a sub-query. */ - QSharedPointer forSubQuery() const final; + std::shared_ptr forSubQuery() const final; private: /*! The type of join being performed. */ diff --git a/include/orm/query/querybuilder.hpp b/include/orm/query/querybuilder.hpp index 0f1db8cb4..0b4cba275 100644 --- a/include/orm/query/querybuilder.hpp +++ b/include/orm/query/querybuilder.hpp @@ -499,7 +499,7 @@ namespace Orm::Query /*! Get the table associated with the query builder. */ inline const FromClause &getFrom() const; /*! Get the table joins for the query. */ - inline const QVector> &getJoins() const; + inline const QVector> &getJoins() const; /*! Get the where constraints for the query. */ inline const QVector &getWheres() const; /*! Get the groupings for the query. */ @@ -517,18 +517,18 @@ namespace Orm::Query /* Other methods */ /*! Get a new instance of the query builder. */ - virtual QSharedPointer newQuery() const; + virtual std::shared_ptr newQuery() const; /*! Create a new query instance for nested where condition. */ - QSharedPointer forNestedWhere() const; + std::shared_ptr forNestedWhere() const; /*! Create a raw database expression. */ Expression raw(const QVariant &value) const; /*! Add another query builder as a nested where to the query builder. */ - Builder &addNestedWhereQuery(const QSharedPointer &query, + Builder &addNestedWhereQuery(const std::shared_ptr &query, const QString &condition); /*! Add an "exists" clause to the query. */ - Builder &addWhereExistsQuery(const QSharedPointer &query, + Builder &addWhereExistsQuery(const std::shared_ptr &query, const QString &condition = AND, bool nope = false); /*! Merge an array of where clauses and bindings. */ @@ -567,11 +567,11 @@ namespace Orm::Query const QString &condition = AND); /*! Get a new join clause. */ - QSharedPointer + std::shared_ptr newJoinClause(const Builder &query, const QString &type, const QString &table) const; /*! Get a new join clause. */ - QSharedPointer + std::shared_ptr newJoinClause(const Builder &query, const QString &type, Expression &&table) const; @@ -602,7 +602,7 @@ namespace Orm::Query std::is_invocable_v; /*! Create a new query instance for a sub-query. */ - inline virtual QSharedPointer forSubQuery() const; + inline virtual std::shared_ptr forSubQuery() const; /*! Prepend the database name if the given query is on another database. */ Builder &prependDatabaseNameIfCrossDatabaseQuery(Builder &query) const; @@ -624,14 +624,14 @@ namespace Orm::Query /*! Add a join clause to the query, common code. */ Builder &joinInternal( - QSharedPointer &&join, const QString &first, + std::shared_ptr &&join, const QString &first, const QString &comparison, const QVariant &second, bool where); /*! Add an advanced join clause to the query, common code. */ Builder &joinInternal( - QSharedPointer &&join, + std::shared_ptr &&join, const std::function &callback); /*! Add a join clause to the query, common code for the above two methods. */ - Builder &joinInternal(QSharedPointer &&join); + Builder &joinInternal(std::shared_ptr &&join); /*! Add a subquery join clause to the query, common code. */ Builder &joinSubInternal( @@ -682,7 +682,7 @@ namespace Orm::Query /*! The table which the query is targeting. */ FromClause m_from {}; /*! The table joins for the query. */ - QVector> m_joins {}; + QVector> m_joins {}; /*! The where constraints for the query. */ QVector m_wheres {}; /*! The groupings for the query. */ @@ -841,7 +841,7 @@ namespace Orm::Query Builder::join(T &&table, const QString &first, const QString &comparison, const QVariant &second, const QString &type, const bool where) { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr return joinInternal(newJoinClause(*this, type, std::forward(table)), first, comparison, second, where); } @@ -852,7 +852,7 @@ namespace Orm::Query Builder::join(T &&table, const std::function &callback, const QString &type) { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr return joinInternal(newJoinClause(*this, type, std::forward(table)), callback); } @@ -1176,7 +1176,7 @@ namespace Orm::Query return m_from; } - const QVector> & + const QVector> & Builder::getJoins() const { return m_joins; @@ -1224,7 +1224,7 @@ namespace Orm::Query /* protected */ - QSharedPointer + std::shared_ptr Builder::forSubQuery() const { return newQuery(); diff --git a/include/orm/tiny/concerns/queriesrelationships.hpp b/include/orm/tiny/concerns/queriesrelationships.hpp index f6940c174..2fc18f44e 100644 --- a/include/orm/tiny/concerns/queriesrelationships.hpp +++ b/include/orm/tiny/concerns/queriesrelationships.hpp @@ -219,7 +219,7 @@ namespace Private /*! Add a sub-query count clause to this query. */ TinyBuilder & addWhereCountQuery( - const QSharedPointer &query, + const std::shared_ptr &query, const QString &comparison = GE, qint64 count = 1, const QString &condition = AND); @@ -508,7 +508,7 @@ namespace Private template TinyBuilder & QueriesRelationships::addWhereCountQuery( - const QSharedPointer &query, const QString &comparison, + const std::shared_ptr &query, const QString &comparison, const qint64 count, const QString &condition) { this->query().getQuery().addBinding(query->getBindings(), BindingType::WHERE); diff --git a/include/orm/tiny/model.hpp b/include/orm/tiny/model.hpp index 21c6d9481..1bae94221 100644 --- a/include/orm/tiny/model.hpp +++ b/include/orm/tiny/model.hpp @@ -172,7 +172,7 @@ namespace Orm::Tiny std::unique_ptr> newQueryWithoutRelationships(); /*! Create a new Tiny query builder for the model. */ std::unique_ptr> - newTinyBuilder(const QSharedPointer &query); + newTinyBuilder(const std::shared_ptr &query); /*! Create a new model instance that is existing. */ Derived newFromBuilder(const QVector &attributes = {}, @@ -230,7 +230,7 @@ namespace Orm::Tiny protected: /* Model Instance methods */ /*! Get a new query builder instance for the connection. */ - QSharedPointer newBaseQueryBuilder() const; + std::shared_ptr newBaseQueryBuilder() const; /* Operations on a model instance */ /*! Perform the actual delete query on this model instance. */ @@ -736,7 +736,7 @@ namespace Orm::Tiny std::unique_ptr> Model::newModelQuery() { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr const auto query = newBaseQueryBuilder(); /* Model is passed to the TinyBuilder ctor, because of that setModel() @@ -755,7 +755,7 @@ namespace Orm::Tiny template std::unique_ptr> Model::newTinyBuilder( - const QSharedPointer &query) + const std::shared_ptr &query) { return std::make_unique>(query, model()); } @@ -965,7 +965,7 @@ namespace Orm::Tiny /* Model Instance methods */ template - QSharedPointer + std::shared_ptr Model::newBaseQueryBuilder() const { return getConnection().query(); diff --git a/include/orm/tiny/relations/belongstomany.hpp b/include/orm/tiny/relations/belongstomany.hpp index db36e1039..eda01c7d1 100644 --- a/include/orm/tiny/relations/belongstomany.hpp +++ b/include/orm/tiny/relations/belongstomany.hpp @@ -155,14 +155,14 @@ namespace Orm::Tiny::Relations bool exists = false) const; /*! Create a new query builder for the pivot table. */ - QSharedPointer newPivotQuery() const; + std::shared_ptr newPivotQuery() const; /*! Get a new plain query builder for the pivot table. */ - QSharedPointer newPivotStatement() const; + std::shared_ptr newPivotStatement() const; /*! Get a new pivot statement for a given "other" / "related" ID. */ - QSharedPointer + std::shared_ptr newPivotStatementForId(const QVector &ids) const; /*! Get a new pivot statement for a given "other" / "related" ID. */ - QSharedPointer + std::shared_ptr inline newPivotStatementForId(const QVariant &id) const; /* TinyBuilder proxy methods */ @@ -838,10 +838,10 @@ namespace Orm::Tiny::Relations } template - QSharedPointer + std::shared_ptr BelongsToMany::newPivotQuery() const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = newPivotStatement(); // FEATURE relations, add support for BelongsToMany::where/whereIn/whereNull silverqx @@ -860,7 +860,7 @@ namespace Orm::Tiny::Relations } template - QSharedPointer + std::shared_ptr BelongsToMany::newPivotStatement() const { auto query = this->m_query->getQuery().newQuery(); @@ -871,11 +871,11 @@ namespace Orm::Tiny::Relations } template - QSharedPointer + std::shared_ptr BelongsToMany::newPivotStatementForId( const QVector &ids) const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = newPivotQuery(); query->whereIn(m_relatedPivotKey, ids); @@ -884,7 +884,7 @@ namespace Orm::Tiny::Relations } template - QSharedPointer + std::shared_ptr BelongsToMany::newPivotStatementForId( const QVariant &id) const { @@ -1400,7 +1400,7 @@ namespace Orm::Tiny::Relations { QVector ids; - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = newPivotQuery()->get({m_relatedPivotKey}); while (query.next()) @@ -1841,7 +1841,7 @@ namespace Orm::Tiny::Relations affected = detachUsingCustomClass(ids); else { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = newPivotQuery(); /* If associated IDs were passed to the method we will only delete those diff --git a/include/orm/tiny/tinybuilder.hpp b/include/orm/tiny/tinybuilder.hpp index f6dd3e5b2..ea33df2e7 100644 --- a/include/orm/tiny/tinybuilder.hpp +++ b/include/orm/tiny/tinybuilder.hpp @@ -42,7 +42,7 @@ namespace Orm::Tiny public: /*! Constructor. */ - Builder(const QSharedPointer &query, Model &model); + Builder(const std::shared_ptr &query, Model &model); /*! Get the SQL representation of the query. */ inline QString toSql() const; @@ -158,8 +158,8 @@ namespace Orm::Tiny /*! Get the underlying query builder instance. */ inline QueryBuilder &getQuery() const; // TODO now fix revisit silverqx - /*! Get the underlying query builder instance as a QSharedPointer. */ - inline const QSharedPointer & + /*! Get the underlying query builder instance as a std::shared_ptr. */ + inline const std::shared_ptr & getQuerySharedPointer() const; /*! Get a database connection. */ @@ -204,7 +204,7 @@ namespace Orm::Tiny // Args &&...parameters); /*! The base query builder instance. */ - const QSharedPointer m_query; + const std::shared_ptr m_query; /* This can't be a reference because the model is created on the stack in Model::query(), then copied here and the original is destroyed immediately. */ @@ -215,7 +215,7 @@ namespace Orm::Tiny }; template - Builder::Builder(const QSharedPointer &query, + Builder::Builder(const std::shared_ptr &query, Model &model) : m_query(query) , m_model(model) @@ -690,7 +690,7 @@ namespace Orm::Tiny } template - const QSharedPointer & + const std::shared_ptr & Builder::getQuerySharedPointer() const { return m_query; diff --git a/include/orm/tiny/tinybuilderproxies.hpp b/include/orm/tiny/tinybuilderproxies.hpp index 7b4b271e7..8e99a97ae 100644 --- a/include/orm/tiny/tinybuilderproxies.hpp +++ b/include/orm/tiny/tinybuilderproxies.hpp @@ -425,7 +425,7 @@ namespace Tiny /* Others proxy methods, not added to the Model and Relation */ /*! Add an "exists" clause to the query. */ TinyBuilder & - addWhereExistsQuery(const QSharedPointer &query, + addWhereExistsQuery(const std::shared_ptr &query, const QString &condition = AND, bool nope = false); /*! Merge an array of where clauses and bindings. */ @@ -1412,7 +1412,7 @@ namespace Tiny template TinyBuilder & BuilderProxies::addWhereExistsQuery( - const QSharedPointer &query, const QString &condition, + const std::shared_ptr &query, const QString &condition, const bool nope) { toBase().addWhereExistsQuery(query, condition, nope); diff --git a/include/pch.h b/include/pch.h index c4e76dd5c..a4568bbc2 100644 --- a/include/pch.h +++ b/include/pch.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/orm/databaseconnection.cpp b/src/orm/databaseconnection.cpp index 13c3f18be..890024e12 100644 --- a/src/orm/databaseconnection.cpp +++ b/src/orm/databaseconnection.cpp @@ -46,10 +46,10 @@ DatabaseConnection::DatabaseConnection( , m_hostName(getConfig(host_).value()) {} -QSharedPointer +std::shared_ptr DatabaseConnection::table(const QString &table, const QString &as) { - auto builder = QSharedPointer::create(*this, *m_queryGrammar); + auto builder = std::make_shared(*this, *m_queryGrammar); builder->from(table, as); @@ -72,9 +72,9 @@ BaseGrammar &DatabaseConnection::withTablePrefix(BaseGrammar &grammar) const return grammar; } -QSharedPointer DatabaseConnection::query() +std::shared_ptr DatabaseConnection::query() { - return QSharedPointer::create(*this, *m_queryGrammar); + return std::make_shared(*this, *m_queryGrammar); } /* Running SQL Queries */ diff --git a/src/orm/databasemanager.cpp b/src/orm/databasemanager.cpp index 7f8794d1e..93c79241d 100644 --- a/src/orm/databasemanager.cpp +++ b/src/orm/databasemanager.cpp @@ -83,20 +83,20 @@ DatabaseManager::create(const ConfigurationsType &configs, new DatabaseManager(configs, defaultConnection)); } -QSharedPointer +std::shared_ptr DatabaseManager::table(const QString &table, const QString &connection) { return this->connection(connection).table(table); } -QSharedPointer +std::shared_ptr DatabaseManager::tableAs(const QString &table, const QString &as, const QString &connection) { return this->connection(connection).table(table, as); } -QSharedPointer +std::shared_ptr DatabaseManager::query(const QString &connection) { return this->connection(connection).query(); diff --git a/src/orm/db.cpp b/src/orm/db.cpp index ca9af2128..8c314dabf 100644 --- a/src/orm/db.cpp +++ b/src/orm/db.cpp @@ -1,7 +1,5 @@ #include "orm/db.hpp" -#include - #include "orm/macros/likely.hpp" TINYORM_BEGIN_COMMON_NAMESPACE @@ -138,19 +136,19 @@ DB::setReconnector(const ReconnectorType &reconnector) return manager().setReconnector(reconnector); } -QSharedPointer +std::shared_ptr DB::table(const QString &table, const QString &connection) { return manager().connection(connection).table(table); } -QSharedPointer +std::shared_ptr DB::tableAs(const QString &table, const QString &as, const QString &connection) { return manager().connection(connection).table(table, as); } -QSharedPointer +std::shared_ptr DB::query(const QString &connection) { return manager().connection(connection).query(); diff --git a/src/orm/query/joinclause.cpp b/src/orm/query/joinclause.cpp index 464e1a9c3..30011afcd 100644 --- a/src/orm/query/joinclause.cpp +++ b/src/orm/query/joinclause.cpp @@ -58,12 +58,12 @@ JoinClause::orOn(const QString &first, const QString &comparison, return on(first, comparison, second, OR); } -QSharedPointer JoinClause::newQuery() const +std::shared_ptr JoinClause::newQuery() const { - return QSharedPointer::create(*this, m_type, m_table); + return std::make_shared(*this, m_type, m_table); } -QSharedPointer JoinClause::forSubQuery() const +std::shared_ptr JoinClause::forSubQuery() const { return Builder::newQuery(); } diff --git a/src/orm/query/querybuilder.cpp b/src/orm/query/querybuilder.cpp index c503c0c56..6a9c7dd47 100644 --- a/src/orm/query/querybuilder.cpp +++ b/src/orm/query/querybuilder.cpp @@ -325,7 +325,7 @@ Builder &Builder::fromRaw(const QString &expression, const QVector &bi Builder &Builder::where(const std::function &callback, const QString &condition) { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr const auto query = forNestedWhere(); std::invoke(callback, *query); @@ -750,15 +750,15 @@ Builder &Builder::setBindings(QVector &&bindings, const BindingType ty /* Other methods */ -// TODO next revisit QSharedPointer, after few weeks I'm pretty sure that this can/should be std::unique_pre, like in the TinyBuilder, I need to check if more instances need to save this pointer at once, if don't then I have to change it silverqx -QSharedPointer Builder::newQuery() const +// TODO next revisit std::shared_ptr, after few weeks I'm pretty sure that this can/should be std::unique_pre, like in the TinyBuilder, I need to check if more instances need to save this pointer at once, if don't then I have to change it silverqx +std::shared_ptr Builder::newQuery() const { - return QSharedPointer::create(m_connection, m_grammar); + return std::make_shared(m_connection, m_grammar); } -QSharedPointer Builder::forNestedWhere() const +std::shared_ptr Builder::forNestedWhere() const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = newQuery(); query->setFrom(m_from); @@ -772,7 +772,7 @@ Expression Builder::raw(const QVariant &value) const } // TODO now, (still need to be revisited) it can be reference, shared owner will be callee, and copy will be made during m_wheres.append() silverqx -Builder &Builder::addNestedWhereQuery(const QSharedPointer &query, +Builder &Builder::addNestedWhereQuery(const std::shared_ptr &query, const QString &condition) { if (query->m_wheres.isEmpty()) @@ -791,7 +791,7 @@ Builder &Builder::addNestedWhereQuery(const QSharedPointer &query, // CUR1 add whereExists() silverqx // CUR1 also add exists() silverqx -Builder &Builder::addWhereExistsQuery(const QSharedPointer &query, +Builder &Builder::addWhereExistsQuery(const std::shared_ptr &query, const QString &condition, const bool nope) { const auto type = nope ? WhereType::NOT_EXISTS : WhereType::EXISTS; @@ -908,20 +908,20 @@ Builder::addArrayOfWheres(const QVector &values, }, condition); } -QSharedPointer +std::shared_ptr Builder::newJoinClause(const Builder &query, const QString &type, const QString &table) const { /* It has to be shared pointer, because it can not be passed down to joinInternal() in join() as incomplete type. */ - return QSharedPointer::create(query, type, table); + return std::make_shared(query, type, table); } -QSharedPointer +std::shared_ptr Builder::newJoinClause(const Builder &query, const QString &type, Expression &&table) const { - return QSharedPointer::create(query, type, std::move(table)); + return std::make_shared(query, type, std::move(table)); } Builder &Builder::clearColumns() @@ -955,7 +955,7 @@ Builder::onceWithColumns( std::pair> Builder::createSub(const std::function &callback) const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr const auto query = forSubQuery(); std::invoke(callback, *query); @@ -1037,7 +1037,7 @@ QSqlQuery Builder::runSelect() } Builder &Builder::joinInternal( - QSharedPointer &&join, const QString &first, + std::shared_ptr &&join, const QString &first, const QString &comparison, const QVariant &second, const bool where) { if (where) @@ -1049,7 +1049,7 @@ Builder &Builder::joinInternal( return joinInternal(std::move(join)); } -Builder &Builder::joinInternal(QSharedPointer &&join, +Builder &Builder::joinInternal(std::shared_ptr &&join, const std::function &callback) { std::invoke(callback, *join); @@ -1058,7 +1058,7 @@ Builder &Builder::joinInternal(QSharedPointer &&join, return joinInternal(std::move(join)); } -Builder &Builder::joinInternal(QSharedPointer &&join) +Builder &Builder::joinInternal(std::shared_ptr &&join) { // For convenience, I want to append first and afterwards add bindings const auto &joinRef = *join; diff --git a/tests/TinyUtils/src/pch.h b/tests/TinyUtils/src/pch.h index e3204125b..425abe9a2 100644 --- a/tests/TinyUtils/src/pch.h +++ b/tests/TinyUtils/src/pch.h @@ -9,7 +9,6 @@ //#include #include #include -#include #include #include #include diff --git a/tests/auto/functional/orm/query/querybuilder/tst_querybuilder.cpp b/tests/auto/functional/orm/query/querybuilder/tst_querybuilder.cpp index d3a75d208..1e4f00354 100644 --- a/tests/auto/functional/orm/query/querybuilder/tst_querybuilder.cpp +++ b/tests/auto/functional/orm/query/querybuilder/tst_querybuilder.cpp @@ -43,7 +43,7 @@ private Q_SLOTS: // NOLINTNEXTLINE(readability-redundant-access-specifiers) private: /*! Create QueryBuilder instance for the given connection. */ - [[nodiscard]] QSharedPointer + [[nodiscard]] std::shared_ptr createQuery(const QString &connection) const; }; @@ -323,7 +323,7 @@ void tst_QueryBuilder::limit() const } } -QSharedPointer +std::shared_ptr tst_QueryBuilder::createQuery(const QString &connection) const { return DB::connection(connection).query(); diff --git a/tests/auto/unit/orm/databaseconnection/tst_databaseconnection.cpp b/tests/auto/unit/orm/databaseconnection/tst_databaseconnection.cpp index ac3a954b5..670d61636 100644 --- a/tests/auto/unit/orm/databaseconnection/tst_databaseconnection.cpp +++ b/tests/auto/unit/orm/databaseconnection/tst_databaseconnection.cpp @@ -44,7 +44,7 @@ private Q_SLOTS: // NOLINTNEXTLINE(readability-redundant-access-specifiers) private: /*! Create QueryBuilder instance for the given connection. */ - [[nodiscard]] QSharedPointer + [[nodiscard]] std::shared_ptr createQuery(const QString &connection) const; }; @@ -254,7 +254,7 @@ void tst_DatabaseConnection::transaction_Commit_Double() const } // Clean up - // Ownerships of the QSharedPointer + // Ownerships of the std::shared_ptr createQuery(connection)->from("users").remove(id1); createQuery(connection)->from("users").remove(id2); } @@ -408,7 +408,7 @@ void tst_DatabaseConnection::transaction_Savepoints_Commit_AllSuccess() const // Clean up while (query.next()) - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr createQuery(connection)->from("users").remove(query.value(ID).value()); } @@ -502,7 +502,7 @@ void tst_DatabaseConnection::transaction_Savepoints_Commit_OneFailed() const // Clean up while (query.next()) - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr createQuery(connection)->from("users").remove(query.value(ID).value()); } @@ -778,7 +778,7 @@ void tst_DatabaseConnection::transaction_Savepoints_Commit_AllFailed_Double() co } } -QSharedPointer +std::shared_ptr tst_DatabaseConnection::createQuery(const QString &connection) const { return DB::connection(connection).query(); diff --git a/tests/auto/unit/orm/query/mysql_querybuilder/tst_mysql_querybuilder.cpp b/tests/auto/unit/orm/query/mysql_querybuilder/tst_mysql_querybuilder.cpp index 1d3b83692..73875954c 100644 --- a/tests/auto/unit/orm/query/mysql_querybuilder/tst_mysql_querybuilder.cpp +++ b/tests/auto/unit/orm/query/mysql_querybuilder/tst_mysql_querybuilder.cpp @@ -153,7 +153,7 @@ private Q_SLOTS: // NOLINTNEXTLINE(readability-redundant-access-specifiers) private: /*! Create QueryBuilder instance for the given connection. */ - [[nodiscard]] QSharedPointer createQuery() const; + [[nodiscard]] std::shared_ptr createQuery() const; /*! Connection name used in this test case. */ QString m_connection {}; @@ -619,7 +619,7 @@ void tst_MySql_QueryBuilder::selectSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("torrents") .select(Raw("max(size)")) @@ -923,7 +923,7 @@ void tst_MySql_QueryBuilder::fromSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("user_sessions") .select({ID, NAME}) @@ -980,7 +980,7 @@ void tst_MySql_QueryBuilder::joinSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("user_sessions") .select({"id as files_id", "user_id", NAME}) @@ -2058,7 +2058,7 @@ void tst_MySql_QueryBuilder::remove_WithExpression() const QVERIFY(firstLog.boundValues.isEmpty()); } -QSharedPointer +std::shared_ptr tst_MySql_QueryBuilder::createQuery() const { return DB::connection(m_connection).query(); diff --git a/tests/auto/unit/orm/query/postgresql_querybuilder/tst_postgresql_querybuilder.cpp b/tests/auto/unit/orm/query/postgresql_querybuilder/tst_postgresql_querybuilder.cpp index 117ad8d0c..16ec28e04 100644 --- a/tests/auto/unit/orm/query/postgresql_querybuilder/tst_postgresql_querybuilder.cpp +++ b/tests/auto/unit/orm/query/postgresql_querybuilder/tst_postgresql_querybuilder.cpp @@ -115,7 +115,7 @@ private Q_SLOTS: // NOLINTNEXTLINE(readability-redundant-access-specifiers) private: /*! Create QueryBuilder instance for the given connection. */ - [[nodiscard]] QSharedPointer createQuery() const; + [[nodiscard]] std::shared_ptr createQuery() const; /*! Connection name used in this test case. */ QString m_connection {}; @@ -663,7 +663,7 @@ void tst_PostgreSQL_QueryBuilder::fromSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("user_sessions") .select({ID, NAME}) @@ -721,7 +721,7 @@ void tst_PostgreSQL_QueryBuilder::joinSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("user_sessions") .select({"id as files_id", "user_id", NAME}) @@ -1648,7 +1648,7 @@ void tst_PostgreSQL_QueryBuilder::remove_WithExpression() const QVERIFY(firstLog.boundValues.isEmpty()); } -QSharedPointer +std::shared_ptr tst_PostgreSQL_QueryBuilder::createQuery() const { return DB::connection(m_connection).query(); diff --git a/tests/auto/unit/orm/query/sqlite_querybuilder/tst_sqlite_querybuilder.cpp b/tests/auto/unit/orm/query/sqlite_querybuilder/tst_sqlite_querybuilder.cpp index a8db11bd2..e6ac794bb 100644 --- a/tests/auto/unit/orm/query/sqlite_querybuilder/tst_sqlite_querybuilder.cpp +++ b/tests/auto/unit/orm/query/sqlite_querybuilder/tst_sqlite_querybuilder.cpp @@ -114,7 +114,7 @@ private Q_SLOTS: // NOLINTNEXTLINE(readability-redundant-access-specifiers) private: /*! Create QueryBuilder instance for the given connection. */ - [[nodiscard]] QSharedPointer createQuery() const; + [[nodiscard]] std::shared_ptr createQuery() const; /*! Connection name used in this test case. */ QString m_connection {}; @@ -622,7 +622,7 @@ void tst_SQLite_QueryBuilder::fromSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("user_sessions") .select({ID, NAME}) @@ -680,7 +680,7 @@ void tst_SQLite_QueryBuilder::joinSub_QueryBuilderOverload_WithWhere() const { auto builder = createQuery(); - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto subQuery = createQuery(); subQuery->from("user_sessions") .select({"id as files_id", "user_id", NAME}) @@ -1601,7 +1601,7 @@ void tst_SQLite_QueryBuilder::remove_WithExpression() const QVERIFY(firstLog.boundValues.isEmpty()); } -QSharedPointer +std::shared_ptr tst_SQLite_QueryBuilder::createQuery() const { return DB::connection(m_connection).query(); diff --git a/tom/include/tom/migrationrepository.hpp b/tom/include/tom/migrationrepository.hpp index c84d2d45a..7f5aae5a2 100644 --- a/tom/include/tom/migrationrepository.hpp +++ b/tom/include/tom/migrationrepository.hpp @@ -2,15 +2,16 @@ #ifndef TOM_MIGRATIONREPOSITORY_HPP #define TOM_MIGRATIONREPOSITORY_HPP -#include - +#include #include +#include #include #include "tom/tomtypes.hpp" class QSqlQuery; +class QVariant; TINYORM_BEGIN_COMMON_NAMESPACE @@ -73,7 +74,7 @@ namespace Tom protected: /*! Get a query builder for the migration table. */ - QSharedPointer table() const; + std::shared_ptr table() const; /*! Hydrate a vector of migration items from a raw QSqlQuery. */ std::vector hydrateMigrations(QSqlQuery &query) const; diff --git a/tom/src/tom/migrationrepository.cpp b/tom/src/tom/migrationrepository.cpp index 2de5fb18f..6a3e9c879 100644 --- a/tom/src/tom/migrationrepository.cpp +++ b/tom/src/tom/migrationrepository.cpp @@ -34,7 +34,7 @@ MigrationRepository::MigrationRepository( QVector MigrationRepository::getRanSimple() const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr return table() ->orderBy(batch_, ASC) .orderBy(migration_, ASC) @@ -43,7 +43,7 @@ QVector MigrationRepository::getRanSimple() const std::vector MigrationRepository::getRan(const QString &order) const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = table() ->orderBy(batch_, order) .orderBy(migration_, order) @@ -54,7 +54,7 @@ std::vector MigrationRepository::getRan(const QString &order) con std::vector MigrationRepository::getMigrations(const int steps) const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = table()->where(batch_, GE, 1) .orderBy(batch_, DESC) .orderBy(migration_, DESC) @@ -66,7 +66,7 @@ std::vector MigrationRepository::getMigrations(const int steps) c std::vector MigrationRepository::getLast() const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr auto query = table()->whereEq(batch_, getLastBatchNumber()) .orderBy(migration_, DESC) .get(); @@ -76,7 +76,7 @@ std::vector MigrationRepository::getLast() const std::map MigrationRepository::getMigrationBatches() const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr return table() ->orderBy(batch_, ASC) .orderBy(migration_, ASC) @@ -85,13 +85,13 @@ std::map MigrationRepository::getMigrationBatches() const void MigrationRepository::log(const QString &file, const int batch) const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr table()->insert({{migration_, file}, {batch_, batch}}); } void MigrationRepository::deleteMigration(const quint64 id) const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr table()->deleteRow(id); } @@ -102,7 +102,7 @@ int MigrationRepository::getNextBatchNumber() const int MigrationRepository::getLastBatchNumber() const { - // Ownership of the QSharedPointer + // Ownership of the std::shared_ptr // Will be 0 on empty migrations table return table()->max(batch_).value(); } @@ -144,7 +144,7 @@ DatabaseConnection &MigrationRepository::connection() const /* protected */ -QSharedPointer MigrationRepository::table() const +std::shared_ptr MigrationRepository::table() const { return connection().table(m_table); }