diff --git a/cmake/Modules/TinySources.cmake b/cmake/Modules/TinySources.cmake index 5a6cbc44f..b740cd81e 100644 --- a/cmake/Modules/TinySources.cmake +++ b/cmake/Modules/TinySources.cmake @@ -142,7 +142,6 @@ function(tiny_sources out_headers out_sources) libraryinfo.cpp mysqlconnection.cpp postgresconnection.cpp - query/expression.cpp query/grammars/grammar.cpp query/grammars/mysqlgrammar.cpp query/grammars/postgresgrammar.cpp diff --git a/include/orm/query/expression.hpp b/include/orm/query/expression.hpp index 55a29e212..4a1757c41 100644 --- a/include/orm/query/expression.hpp +++ b/include/orm/query/expression.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_EXPRESSION_HPP -#define ORM_EXPRESSION_HPP +#ifndef ORM_QUERY_EXPRESSION_HPP +#define ORM_QUERY_EXPRESSION_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -9,7 +9,6 @@ TINY_SYSTEM_HEADER #include #include "orm/macros/commonnamespace.hpp" -#include "orm/macros/export.hpp" TINYORM_BEGIN_COMMON_NAMESPACE @@ -17,7 +16,7 @@ namespace Orm::Query { /*! Expression in sql query. */ - class SHAREDLIB_EXPORT Expression + class Expression { public: /*! Default constructor, needed by Q_DECLARE_METATYPE. */ @@ -26,9 +25,9 @@ namespace Orm::Query inline ~Expression() = default; /*! Converting constructor from QVariant type. */ - explicit Expression(const QVariant &value); + inline explicit Expression(const QVariant &value); /*! Converting constructor from QVariant type. */ - explicit Expression(QVariant &&value); + inline explicit Expression(QVariant &&value); /*! Copy constructor. */ inline Expression(const Expression &) = default; @@ -41,10 +40,10 @@ namespace Orm::Query inline Expression &operator=(Expression &&) = default; /*! Converting operator, QVariant(Expression). */ - operator QVariant() const; // NOLINT(google-explicit-constructor) + inline operator QVariant() const; // NOLINT(google-explicit-constructor) /*! Obtain expression's value. */ - const QVariant &getValue() const; + inline const QVariant &getValue() const; /*! Equality operator, the inequality operator is automatically generated. */ inline bool operator==(const Expression &) const = default; @@ -54,7 +53,21 @@ namespace Orm::Query QVariant m_value {}; }; - inline const QVariant &Expression::getValue() const + // NOLINTNEXTLINE(modernize-pass-by-value) + Expression::Expression(const QVariant &value) + : m_value(value) + {} + + Expression::Expression(QVariant &&value) + : m_value(std::move(value)) + {} + + Expression::operator QVariant() const + { + return QVariant::fromValue(*this); + } + + const QVariant &Expression::getValue() const { return m_value; } @@ -71,4 +84,4 @@ Q_DECLARE_METATYPE(TINYORM_COMMON_NAMESPACE::Orm::Query::Expression) Q_DECLARE_METATYPE(Orm::Query::Expression) #endif -#endif // ORM_EXPRESSION_HPP +#endif // ORM_QUERY_EXPRESSION_HPP diff --git a/include/orm/query/joinclause.hpp b/include/orm/query/joinclause.hpp index 59d561778..49fbe9623 100644 --- a/include/orm/query/joinclause.hpp +++ b/include/orm/query/joinclause.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_JOINCLAUSE_HPP -#define ORM_JOINCLAUSE_HPP +#ifndef ORM_QUERY_JOINCLAUSE_HPP +#define ORM_QUERY_JOINCLAUSE_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -39,9 +39,9 @@ namespace Orm::Query const QString &second); /*! Get the type of join being performed. */ - const QString &getType() const; + inline const QString &getType() const; /*! Get the table the join clause is joining to. */ - const std::variant & + inline const std::variant & getTable() const; /*! Get a new instance of the join clause builder. */ @@ -58,13 +58,13 @@ namespace Orm::Query const JoinTable m_table; }; - inline const QString & + const QString & JoinClause::getType() const { return m_type; } - inline const std::variant & + const std::variant & JoinClause::getTable() const { return m_table; @@ -74,4 +74,4 @@ namespace Orm::Query TINYORM_END_COMMON_NAMESPACE -#endif // ORM_JOINCLAUSE_HPP +#endif // ORM_QUERY_JOINCLAUSE_HPP diff --git a/include/orm/query/processors/mysqlprocessor.hpp b/include/orm/query/processors/mysqlprocessor.hpp index e0261f3d9..34c7ca1b0 100644 --- a/include/orm/query/processors/mysqlprocessor.hpp +++ b/include/orm/query/processors/mysqlprocessor.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_PROCESSORS_MYSQLPROCESSOR_HPP -#define ORM_PROCESSORS_MYSQLPROCESSOR_HPP +#ifndef ORM_QUERY_PROCESSORS_MYSQLPROCESSOR_HPP +#define ORM_QUERY_PROCESSORS_MYSQLPROCESSOR_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -31,4 +31,4 @@ namespace Orm::Query::Processors TINYORM_END_COMMON_NAMESPACE -#endif // ORM_PROCESSORS_MYSQLPROCESSOR_HPP +#endif // ORM_QUERY_PROCESSORS_MYSQLPROCESSOR_HPP diff --git a/include/orm/query/processors/postgresprocessor.hpp b/include/orm/query/processors/postgresprocessor.hpp index 66b9f129d..2793dc85a 100644 --- a/include/orm/query/processors/postgresprocessor.hpp +++ b/include/orm/query/processors/postgresprocessor.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_PROCESSORS_POSTGRESPROCESSOR_HPP -#define ORM_PROCESSORS_POSTGRESPROCESSOR_HPP +#ifndef ORM_QUERY_PROCESSORS_POSTGRESPROCESSOR_HPP +#define ORM_QUERY_PROCESSORS_POSTGRESPROCESSOR_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -31,4 +31,4 @@ namespace Orm::Query::Processors TINYORM_END_COMMON_NAMESPACE -#endif // ORM_PROCESSORS_POSTGRESPROCESSOR_HPP +#endif // ORM_QUERY_PROCESSORS_POSTGRESPROCESSOR_HPP diff --git a/include/orm/query/processors/processor.hpp b/include/orm/query/processors/processor.hpp index 0156a410e..34c16f721 100644 --- a/include/orm/query/processors/processor.hpp +++ b/include/orm/query/processors/processor.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_PROCESSORS_PROCESSOR_HPP -#define ORM_PROCESSORS_PROCESSOR_HPP +#ifndef ORM_QUERY_PROCESSORS_PROCESSOR_HPP +#define ORM_QUERY_PROCESSORS_PROCESSOR_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -37,4 +37,4 @@ namespace Orm::Query::Processors TINYORM_END_COMMON_NAMESPACE -#endif // ORM_PROCESSORS_PROCESSOR_HPP +#endif // ORM_QUERY_PROCESSORS_PROCESSOR_HPP diff --git a/include/orm/query/processors/sqliteprocessor.hpp b/include/orm/query/processors/sqliteprocessor.hpp index 52fd50a48..42ec96c43 100644 --- a/include/orm/query/processors/sqliteprocessor.hpp +++ b/include/orm/query/processors/sqliteprocessor.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_PROCESSORS_SQLITEPROCESSOR_HPP -#define ORM_PROCESSORS_SQLITEPROCESSOR_HPP +#ifndef ORM_QUERY_PROCESSORS_SQLITEPROCESSOR_HPP +#define ORM_QUERY_PROCESSORS_SQLITEPROCESSOR_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -31,4 +31,4 @@ namespace Orm::Query::Processors TINYORM_END_COMMON_NAMESPACE -#endif // ORM_PROCESSORS_SQLITEPROCESSOR_HPP +#endif // ORM_QUERY_PROCESSORS_SQLITEPROCESSOR_HPP diff --git a/include/orm/query/querybuilder.hpp b/include/orm/query/querybuilder.hpp index 6517dc3ce..365ff3572 100644 --- a/include/orm/query/querybuilder.hpp +++ b/include/orm/query/querybuilder.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef ORM_QUERYBUILDER_HPP -#define ORM_QUERYBUILDER_HPP +#ifndef ORM_QUERY_QUERYBUILDER_HPP +#define ORM_QUERY_QUERYBUILDER_HPP #include "orm/macros/systemheader.hpp" TINY_SYSTEM_HEADER @@ -29,7 +29,6 @@ namespace Query concept Remove = std::convertible_to || std::same_as; - // FEATURE subqueries, add support for subqueries, first in where() silverqx // TODO add inRandomOrder() silverqx // TODO QueryBuilder::updateOrInsert() silverqx /*! Database query builder. */ @@ -1207,4 +1206,4 @@ namespace Query TINYORM_END_COMMON_NAMESPACE -#endif // ORM_QUERYBUILDER_HPP +#endif // ORM_QUERY_QUERYBUILDER_HPP diff --git a/src/orm/connectors/connector.cpp b/src/orm/connectors/connector.cpp index 116e8aba3..88647b69e 100644 --- a/src/orm/connectors/connector.cpp +++ b/src/orm/connectors/connector.cpp @@ -18,7 +18,7 @@ namespace Orm::Connectors { const QString Connector::m_configureErrorMessage = - "Connection configuration statement in %1() failed."; + QStringLiteral("Connection configuration statement in %1() failed."); QSqlDatabase Connector::createConnection(const QString &name, const QVariantHash &config, diff --git a/src/orm/query/expression.cpp b/src/orm/query/expression.cpp deleted file mode 100644 index 9a6e6729e..000000000 --- a/src/orm/query/expression.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "orm/query/expression.hpp" - -TINYORM_BEGIN_COMMON_NAMESPACE - -namespace Orm::Query -{ - -/* - I don't need QString ctor because QString will be immediately converted - to the QVariant in this constructor. - m_value can not be QString because the Query::Expression still can hold eg. int, - uint, QDateTime, and all other supported types, this is not fully true, it could be - the QString, an explanation is below. - BUT, m_value is always converted to the QString in Grammar and appended to the query - string, anyway I have decided to leave it QVariant because a user can write DB::raw(3) - and not DB::raw(QString::number(3)), it is all about nicer API at the expense - of performance. -*/ - -// NOLINTNEXTLINE(modernize-pass-by-value) -Expression::Expression(const QVariant &value) - : m_value(value) -{} - -Expression::Expression(QVariant &&value) - : m_value(std::move(value)) -{} - -Expression::operator QVariant() const -{ - return QVariant::fromValue(*this); -} - -} // namespace Orm::Query - -TINYORM_END_COMMON_NAMESPACE diff --git a/src/orm/query/querybuilder.cpp b/src/orm/query/querybuilder.cpp index 5a642164e..c86ce9fee 100644 --- a/src/orm/query/querybuilder.cpp +++ b/src/orm/query/querybuilder.cpp @@ -494,7 +494,7 @@ Builder &Builder::having(const Column &column, const QString &comparison, m_havings.append({column, value, comparison, condition, HavingType::BASIC}); if (!value.canConvert()) - // CUR1 check flattenBindings, I already have flatBindingsForUpdateDelete() algo silverqx + // CUR1 check flattenBindings, I already have flatBindingsForUpdateDelete() algorithm silverqx addBinding(value, BindingType::HAVING); return *this; diff --git a/src/src.pri b/src/src.pri index 995f3329f..a3655994d 100644 --- a/src/src.pri +++ b/src/src.pri @@ -20,7 +20,6 @@ sourcesList += \ $$PWD/orm/libraryinfo.cpp \ $$PWD/orm/mysqlconnection.cpp \ $$PWD/orm/postgresconnection.cpp \ - $$PWD/orm/query/expression.cpp \ $$PWD/orm/query/grammars/grammar.cpp \ $$PWD/orm/query/grammars/mysqlgrammar.cpp \ $$PWD/orm/query/grammars/postgresgrammar.cpp \