X-Git-Url: https://git.toastfreeware.priv.at/toast/confclerk.git/blobdiff_plain/d8d5bd26715e044b9ccd6e07e382dcf80b7bdc9a..7d7659d9245bb55bba9043ed269aa92cbd38e8b0:/src/orm/ormrecord.h diff --git a/src/orm/ormrecord.h b/src/orm/ormrecord.h index 2328549..f3c0fcc 100644 --- a/src/orm/ormrecord.h +++ b/src/orm/ormrecord.h @@ -9,19 +9,6 @@ #include #include -// INFO: -// all record items/columns may be defined in one table (1.), or -// they can be splitted in two separate tables (2.) (eg. for FTS support) -// 1.) you have to define "static QString const sTableName" -// 2.) you have to define two table names: -// "static QString const sTable1Name" -// "static QString const sTable2Name" -// and since all record items/columns are handled by one QSqlRecord, -// you have to also define number of columns that belongs to table 1 (1.), and table 2 (2.) -// 1.) "static int const sTable1ColCount" -// 2.) "static int const sTable2ColCount" -// there are also defined auxiliary methods for 1-Table/2-Tables approach, see bellow - class OrmException { }; @@ -61,9 +48,6 @@ protected: static QString columnsForSelect(const QString& prefix = QString()); static QString selectQuery(); static QString updateQuery(); - // record items/columns are stored in two tables - static QString columnsForSelectJoin2T(); // for joining two tables - static QString selectQueryJoin2T(const QString &key); // for joining two tables static QVariant convertToC(QVariant value, QVariant::Type colType); static QVariant convertToDb(QVariant value, QVariant::Type colType); @@ -170,47 +154,16 @@ QString OrmRecord::columnsForSelect(const QString& prefix) return prefixedColumns.join(","); } -template -QString OrmRecord::columnsForSelectJoin2T() -{ - Q_ASSERT((T::sTable1ColCount+T::sTable2ColCount) == T::sColumns.count()); - - QStringList prefixedColumns; - for (int i=0; i QString OrmRecord::selectQuery() { return QString("SELECT %1 FROM %2 ").arg(columnsForSelect(), T::sTableName); } - -template -QString OrmRecord::selectQueryJoin2T(const QString &key) -{ - return QString("SELECT %1 FROM %2 INNER JOIN %3 ON %4.%5 = %6.%7 ").arg( - columnsForSelectJoin2T(), - T::sTable1Name, - T::sTable2Name, - T::sTable1Name, - key, - T::sTable2Name, - key); -} - template QString OrmRecord::updateQuery() { - return QString("UPDATE %1 ").arg(T::sTable1Name); + return QString("UPDATE %1 ").arg(T::sTableName); } template