Changeset 763b877


Ignore:
Timestamp:
08/18/21 21:17:28 (9 months ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master
Children:
a59d5c4
Parents:
ff579df
Message:

Fix bug: display_time_shift was lost when conference was reloaded.

Location:
src/sql
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/sql/schedulexmlparser.cpp

    rff579df r763b877  
    8585            conference["display_time_shift"] = QString();
    8686            conference["url"] = url;
    87             sqlEngine->addConferenceToDB(conference, conferenceId);
     87            sqlEngine->addConferenceToDB(conference, conferenceId, conferenceId != 0);
    8888            conferenceId = conference["id"].toInt();
    8989            conference_title = conference["title"];
     
    193193        // Re-write conference as utc_offset was not known previously
    194194        if (!conference.value("utc_offset").isEmpty()) {
    195             sqlEngine->addConferenceToDB(conference, conferenceId);
     195            sqlEngine->addConferenceToDB(conference, conferenceId, conferenceId != 0);
    196196        }
    197197
  • src/sql/sqlengine.cpp

    rff579df r763b877  
    145145
    146146
    147 void SqlEngine::addConferenceToDB(QHash<QString,QString> &aConference, int conferenceId) {
     147void SqlEngine::addConferenceToDB(QHash<QString,QString> &aConference, int conferenceId, bool omit_display_time_shift) {
    148148    QSqlQuery query(db);
    149149    bool insert = conferenceId <= 0;
     
    154154                                                ":day_change,:timeslot_duration,:utc_offset,:display_time_shift,:active)");
    155155    } else { // update conference
    156         query.prepare("UPDATE CONFERENCE set title=:title, url=:url, subtitle=:subtitle, venue=:venue, city=:city, start=:start, end=:end,"
    157                                             "day_change=:day_change, timeslot_duration=:timeslot_duration, utc_offset=:utc_offset, display_time_shift=:display_time_shift, active=:active "
    158                       "WHERE id=:id");
     156        QString update = "UPDATE CONFERENCE set title=:title, url=:url, subtitle=:subtitle, venue=:venue, city=:city, start=:start, end=:end, "
     157                         "day_change=:day_change, timeslot_duration=:timeslot_duration, utc_offset=:utc_offset";
     158        if (!omit_display_time_shift) update += ", display_time_shift=:display_time_shift";
     159        update += ", active=:active WHERE id=:id";
     160        query.prepare(update);
    159161    }
    160162    foreach (QString prop_name, (QList<QString>() << "title" << "url" << "subtitle" << "venue" << "city")) {
     
    169171    if (!aConference.value("utc_offset").isEmpty()) utc_offset = aConference["utc_offset"].toInt();
    170172    query.bindValue(":utc_offset", utc_offset);
    171     QVariant display_time_shift;
    172     if (!aConference.value("display_time_shift").isEmpty()) display_time_shift = aConference["display_time_shift"].toInt();
    173     query.bindValue(":display_time_shift", display_time_shift);
     173    if (!omit_display_time_shift) {
     174        QVariant display_time_shift;
     175        if (!aConference.value("display_time_shift").isEmpty()) display_time_shift = aConference["display_time_shift"].toInt();
     176        query.bindValue(":display_time_shift", display_time_shift);
     177    }
    174178    query.bindValue(":active", 1);
    175179    if (!insert) query.bindValue(":id", conferenceId);
  • src/sql/sqlengine.h

    rff579df r763b877  
    6060        bool applySqlFile(const QString sqlFile);
    6161
    62         // if a conferneceId != 0 is given, the confernce is updated instead of inserted.
    63         void addConferenceToDB(QHash<QString,QString> &aConference, int conferenceId);
     62        // if a conferenceId != 0 is given, the conference is updated instead of inserted.
     63        void addConferenceToDB(QHash<QString,QString> &aConference, int conferenceId, bool omit_display_time_shift = false);
    6464        void addEventToDB(QHash<QString,QString> &aEvent);
    6565        void addPersonToDB(QHash<QString,QString> &aPerson);
Note: See TracChangeset for help on using the changeset viewer.