From 886cc3c7774cefc796d5e0fcc24a353add497ff5 Mon Sep 17 00:00:00 2001 From: Filip Bucek Date: Thu, 14 Nov 2019 10:54:02 +0100 Subject: [PATCH] added comment about subclassing DataTable --- src/serversdk/databasetable.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/serversdk/databasetable.h b/src/serversdk/databasetable.h index 315d907..dc0e899 100644 --- a/src/serversdk/databasetable.h +++ b/src/serversdk/databasetable.h @@ -129,6 +129,31 @@ public: * @brief Convert QVariant type to SQL type * @param QVariant type ( QString, int, QDateTime ) * @return text form of database type ( INTEGER, TEXT ) + * + * # Sublassing + * + * When it is neccessary to use different type it is possible to subclass and override this method. + * + * @code + class BackendTable : public serversdk::DatabaseTable + { + QString textPostgresType(QVariant::Type type) const override; + } + + BackendTable::textPostgresType(QVariant::Type type) const override + { + // For case when saving date time as ms since epoch + if (type == QVariant::DateTime) { + return QStringLiteral("INTEGER"); + } + return DatabaseTable::textPostgresType(type); + } + + * @endcode + * + * + * + * */ virtual QString textPostgresType(QVariant::Type type) const;