Ignore:
Timestamp:
01/21/10 14:24:08 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
06570e9
Parents:
d8d5bd2
Message:

combined EVENT and VIRTUAL_EVENT => 'EVENT' now

  • Maemo sqlite doesn't support Full-Text-Search
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/orm/ormrecord.h

    rd8d5bd2 r7d7659d  
    1010#include <QDebug>
    1111
    12 // INFO:
    13 // all record items/columns may be defined in one table (1.), or
    14 // they can be splitted in two separate tables (2.) (eg. for FTS support)
    15 // 1.) you have to define "static QString const sTableName"
    16 // 2.) you have to define two table names:
    17 //     "static QString const sTable1Name"
    18 //     "static QString const sTable2Name"
    19 // and since all record items/columns are handled by one QSqlRecord,
    20 // you have to also define number of columns that belongs to table 1 (1.), and table 2 (2.)
    21 // 1.) "static int const sTable1ColCount"
    22 // 2.) "static int const sTable2ColCount"
    23 // there are also defined auxiliary methods for 1-Table/2-Tables approach, see bellow
    24 
    2512class OrmException
    2613{
     
    6249    static QString selectQuery();
    6350    static QString updateQuery();
    64     // record items/columns are stored in two tables
    65     static QString columnsForSelectJoin2T(); // for joining two tables
    66     static QString selectQueryJoin2T(const QString &key); // for joining two tables
    6751
    6852    static QVariant convertToC(QVariant value, QVariant::Type colType);
     
    172156
    173157template <typename T>
    174 QString OrmRecord<T>::columnsForSelectJoin2T()
    175 {
    176     Q_ASSERT((T::sTable1ColCount+T::sTable2ColCount) == T::sColumns.count());
    177 
    178     QStringList prefixedColumns;
    179     for (int i=0; i<T::sTable1ColCount; i++)
    180     {
    181         prefixedColumns.append(QString("%1.%2").arg(T::sTable1Name, T::sColumns.field(i).name()));
    182     }
    183     for (int j=0; j<T::sTable2ColCount; j++)
    184     {
    185         prefixedColumns.append(QString("%1.%2").arg(T::sTable2Name, T::sColumns.field(T::sTable1ColCount+j).name()));
    186     }
    187     return prefixedColumns.join(",");
    188 }
    189 
    190 template <typename T>
    191158QString OrmRecord<T>::selectQuery()
    192159{
     
    194161}
    195162
    196 
    197 template <typename T>
    198 QString OrmRecord<T>::selectQueryJoin2T(const QString &key)
    199 {
    200     return QString("SELECT %1 FROM %2 INNER JOIN %3 ON %4.%5 = %6.%7 ").arg(
    201             columnsForSelectJoin2T(),
    202             T::sTable1Name,
    203             T::sTable2Name,
    204             T::sTable1Name,
    205             key,
    206             T::sTable2Name,
    207             key);
    208 }
    209 
    210163template <typename T>
    211164QString OrmRecord<T>::updateQuery()
    212165{
    213     return QString("UPDATE %1 ").arg(T::sTable1Name);
     166    return QString("UPDATE %1 ").arg(T::sTableName);
    214167}
    215168
Note: See TracChangeset for help on using the changeset viewer.