Changeset 0ea5709


Ignore:
Timestamp:
07/11/11 20:07:18 (10 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
525e2e2
Parents:
334d43d
Message:

Before querying the SEARCH_EVENT table, its existence is checked. Therefore a command line debug error message is avoided.

This commit partly fixes ticket #10.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/event.cpp

    r334d43d r0ea5709  
    221221}
    222222
    223 QList<Event> Event::getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy)
    224 {
     223QList<Event> Event::getSearchResultByDate(const QDate& date, int conferenceId, QString orderBy) {
     224    QList<Event> list;
     225
     226    // Check whether the temporary table SEARCH_EVENT exists (http://www.sqlite.org/faq.html#q7)
     227    QSqlQuery query("SELECT count(*) FROM sqlite_temp_master WHERE type='table' and name='SEARCH_EVENT'");
     228    if (!query.exec()) {
     229        qDebug() << "SQL Error: " << query.lastError().text();
     230        return list;
     231    }
     232    query.first();
     233    QVariant v = query.value(0);
     234    if (v.toInt() != 1) return list;
     235
    225236    QString strQuery = QString("SELECT %1 FROM EVENT INNER JOIN SEARCH_EVENT USING (xid_conference, id) ").arg(columnsForSelect());
    226237    strQuery += QString("WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY %1").arg(orderBy);
    227 
    228     QList<Event> list;
    229     QSqlQuery query;
    230     try{
     238    query = QSqlQuery();
     239    try {
    231240        if( !query.prepare( strQuery ) ){
    232241            qDebug() << "QSqlQuery.prepare error";
Note: See TracChangeset for help on using the changeset viewer.