From 04d3838d87158f2fde74ef37a6ff1a2b30fa647c Mon Sep 17 00:00:00 2001 From: silverqx Date: Sun, 22 May 2022 18:59:27 +0200 Subject: [PATCH] added comments --- include/orm/schema/blueprint.hpp | 6 +++--- include/orm/schema/grammars/mysqlschemagrammar.hpp | 2 ++ include/orm/schema/grammars/postgresschemagrammar.hpp | 2 ++ include/orm/schema/grammars/schemagrammar.hpp | 4 ++++ src/orm/schema/blueprint.cpp | 2 ++ src/orm/schema/grammars/postgresschemagrammar.cpp | 2 ++ src/orm/schema/grammars/schemagrammar.cpp | 8 ++++++++ src/orm/schema/postgresschemabuilder.cpp | 2 ++ 8 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/orm/schema/blueprint.hpp b/include/orm/schema/blueprint.hpp index 6074c36e1..de9962f27 100644 --- a/include/orm/schema/blueprint.hpp +++ b/include/orm/schema/blueprint.hpp @@ -408,11 +408,11 @@ namespace Grammars /*! The default string length for migrations. */ static int DefaultStringLength; - /*! The storage engine that should be used for the table. */ + /*! The storage engine that should be used for the table (MySQL). */ QString engine {}; - /*! The default character set that should be used for the table. */ + /*! The default character set that should be used for the table (MySQL). */ QString charset {}; - /*! The collation that should be used for the table. */ + /*! The collation that should be used for the table (MySQL). */ QString collation {}; protected: diff --git a/include/orm/schema/grammars/mysqlschemagrammar.hpp b/include/orm/schema/grammars/mysqlschemagrammar.hpp index 77e20a236..c96f29d5e 100644 --- a/include/orm/schema/grammars/mysqlschemagrammar.hpp +++ b/include/orm/schema/grammars/mysqlschemagrammar.hpp @@ -275,6 +275,8 @@ namespace Grammars QString modifySrid(const ColumnDefinition &column) const; }; + /* public */ + bool MySqlSchemaGrammar::supportsSchemaTransactions() const noexcept { return false; diff --git a/include/orm/schema/grammars/postgresschemagrammar.hpp b/include/orm/schema/grammars/postgresschemagrammar.hpp index 18f0dbe7e..c47b9d78c 100644 --- a/include/orm/schema/grammars/postgresschemagrammar.hpp +++ b/include/orm/schema/grammars/postgresschemagrammar.hpp @@ -56,6 +56,8 @@ namespace Orm::SchemaNs::Grammars QString getType(const ColumnDefinition &column) const override; }; + /* public */ + bool PostgresSchemaGrammar::supportsSchemaTransactions() const noexcept { return true; diff --git a/include/orm/schema/grammars/schemagrammar.hpp b/include/orm/schema/grammars/schemagrammar.hpp index f194459fe..611901971 100644 --- a/include/orm/schema/grammars/schemagrammar.hpp +++ b/include/orm/schema/grammars/schemagrammar.hpp @@ -112,8 +112,12 @@ namespace Grammars virtual QString typeComputed(const ColumnDefinition &column) const; }; + /* public */ + SchemaGrammar::~SchemaGrammar() = default; + /* others */ + template QVector SchemaGrammar::prefixArray(const QString &prefix, const T &values) const diff --git a/src/orm/schema/blueprint.cpp b/src/orm/schema/blueprint.cpp index aa2427be0..421230249 100644 --- a/src/orm/schema/blueprint.cpp +++ b/src/orm/schema/blueprint.cpp @@ -60,6 +60,7 @@ QVector Blueprint::toSql(const DatabaseConnection &connection, const BasicCommand &Blueprint::create() { + // First {} is for the base class return addCommand({{}, Create}); } @@ -283,6 +284,7 @@ ColumnDefinitionReference<> Blueprint::longText(const QString &column) return addColumn(ColumnType::LongText, column); } +// CUR schema, fix and unify real/double/float types with latest standard and remove deprecated APIs, what I have understood from the MySQL and PostgreSQL docs it should be like this; I should have real and double (double precision) types without any total, places or precision params and then I should have float type that should have precision param, currently this total and places params are depreceted as described in https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html and will be removed in future, also add this column types to tests and to the playground also check numeric/decimal type, its different animal silverqx ColumnDefinitionReference<> Blueprint::Float(const QString &column, const std::optional total, const std::optional places, const bool isUnsigned) diff --git a/src/orm/schema/grammars/postgresschemagrammar.cpp b/src/orm/schema/grammars/postgresschemagrammar.cpp index 6d11e2a22..fd3aaf58e 100644 --- a/src/orm/schema/grammars/postgresschemagrammar.cpp +++ b/src/orm/schema/grammars/postgresschemagrammar.cpp @@ -7,6 +7,8 @@ TINYORM_BEGIN_COMMON_NAMESPACE namespace Orm::SchemaNs::Grammars { +/* public */ + /* Compile methods for the SchemaBuilder */ QString PostgresSchemaGrammar::compileEnableForeignKeyConstraints() const diff --git a/src/orm/schema/grammars/schemagrammar.cpp b/src/orm/schema/grammars/schemagrammar.cpp index 8e764b371..c7a8ae138 100644 --- a/src/orm/schema/grammars/schemagrammar.cpp +++ b/src/orm/schema/grammars/schemagrammar.cpp @@ -9,6 +9,10 @@ TINYORM_BEGIN_COMMON_NAMESPACE namespace Orm::SchemaNs::Grammars { +/* public */ + +/* Compile methods for the SchemaBuilder */ + QString SchemaGrammar::compileCreateDatabase(const QString &/*unused*/, DatabaseConnection &connection) const { @@ -48,6 +52,8 @@ QString SchemaGrammar::compileTableExists() const throw Exceptions::RuntimeError(NotImplemented); } +/* Compile methods for commands */ + QVector SchemaGrammar::compileFullText(const Blueprint &/*unused*/, const IndexCommand &/*unused*/) const @@ -97,6 +103,8 @@ SchemaGrammar::compileDropFullText(const Blueprint &/*unused*/, "This database driver does not support dropping databases."); } +/* Others */ + QString SchemaGrammar::wrap(const ColumnDefinition &column, bool prefixAlias) const { return BaseGrammar::wrap(column.name, prefixAlias); diff --git a/src/orm/schema/postgresschemabuilder.cpp b/src/orm/schema/postgresschemabuilder.cpp index 21b8da993..942a830ec 100644 --- a/src/orm/schema/postgresschemabuilder.cpp +++ b/src/orm/schema/postgresschemabuilder.cpp @@ -7,6 +7,8 @@ TINYORM_BEGIN_COMMON_NAMESPACE namespace Orm::SchemaNs { +/* public */ + QStringList PostgresSchemaBuilder::getColumnListing(const QString &table) const { auto [schema, table_] = parseSchemaAndTable(table);