added comment about subclassing DataTable

This commit is contained in:
Filip Bucek 2019-11-14 10:54:02 +01:00
parent dfe6d3bb03
commit 886cc3c777

View File

@ -129,6 +129,31 @@ public:
* @brief Convert QVariant type to SQL type * @brief Convert QVariant type to SQL type
* @param QVariant type ( QString, int, QDateTime ) * @param QVariant type ( QString, int, QDateTime )
* @return text form of database type ( INTEGER, TEXT ) * @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; virtual QString textPostgresType(QVariant::Type type) const;