New upstream release.
[debian/fosdem-schedule.git] / src / sql / sqlengine.cpp
index 3d4b30e44fa6389cf5fb052e86cd73087f3983b8..90cb989acac948d0e84b98f63a4eebaea08d5feb 100644 (file)
@@ -152,7 +152,10 @@ void SqlEngine::addEventToDB(QHash<QString,QString> &aEvent)
             trackId = track.insert();
             /*qDebug() << QString("DEBUG: Track %1 added to DB").arg(name);*/
         }
-        QDateTime startDateTime = QDateTime(QDate::fromString(aEvent["date"],DATE_FORMAT),QTime::fromString(aEvent["start"],TIME_FORMAT));
+        QDateTime startDateTime;
+        startDateTime.setTimeSpec(Qt::UTC);
+        startDateTime = QDateTime(QDate::fromString(aEvent["date"],DATE_FORMAT),QTime::fromString(aEvent["start"],TIME_FORMAT),Qt::UTC);
+        qDebug() << "startDateTime: " << startDateTime.toString();
         QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7', ? , ? , ? , ? , ? , '%8', '%9'") \
                          .arg(aEvent["conference_id"]) \
                          .arg(aEvent["id"]) \
@@ -168,6 +171,7 @@ void SqlEngine::addEventToDB(QHash<QString,QString> &aEvent)
             QString("INSERT INTO EVENT (xid_conference, id, start, duration, xid_track, type, language, tag, title, subtitle, abstract, description, favourite, alarm) VALUES (%1)")
             .arg(values);
 
+        qDebug() << query;
         QSqlQuery result;
         result.prepare(query);
         result.bindValue(0,aEvent["tag"]);
@@ -293,7 +297,7 @@ bool SqlEngine::createTables(QSqlDatabase &aDatabase)
             "description VARCHAR, "
             "favourite INTEGER DEFAULT 0, "
             "alarm INTEGER DEFAULT 0, "
-            "PRIMARY KEY (xid_conference,id), "
+            "PRIMARY KEY (xid_conference,id) ON CONFLICT REPLACE, "
             "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
             "FOREIGN KEY(xid_track) REFERENCES TRACK(id));");
 
@@ -301,7 +305,7 @@ bool SqlEngine::createTables(QSqlDatabase &aDatabase)
             "xid_conference INTEGER NOT NULL, "
             "xid_event INTEGER NOT NULL, "
             "xid_person INTEGER NOT NULL, "
-            "UNIQUE ( xid_conference, xid_event, xid_person ) ON CONFLICT IGNORE, "
+            "UNIQUE ( xid_conference, xid_event, xid_person ) ON CONFLICT REPLACE, "
             "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
             "FOREIGN KEY(xid_event) REFERENCES EVENT(id), "
             "FOREIGN KEY(xid_person) REFERENCES PERSON(id));");
@@ -310,7 +314,7 @@ bool SqlEngine::createTables(QSqlDatabase &aDatabase)
             "xid_conference INTEGER NOT NULL, "
             "xid_event INTEGER NOT NULL, "
             "xid_room INTEGER NOT NULL, "
-            "UNIQUE ( xid_conference, xid_event, xid_room ) ON CONFLICT IGNORE, "
+            "UNIQUE ( xid_conference, xid_event, xid_room ) ON CONFLICT REPLACE, "
             "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
             "FOREIGN KEY(xid_event) REFERENCES EVENT(id), "
             "FOREIGN KEY(xid_room) REFERENCES ROOM(id));");
@@ -321,7 +325,7 @@ bool SqlEngine::createTables(QSqlDatabase &aDatabase)
             "xid_event INTEGER NOT NULL, "
             "name VARCHAR, "
             "url VARCHAR NOT NULL, "
-            "UNIQUE ( xid_conference, xid_event, url ) ON CONFLICT IGNORE, "
+            "UNIQUE ( xid_conference, xid_event, url ) ON CONFLICT REPLACE, "
             "FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id), "
             "FOREIGN KEY(xid_event) REFERENCES EVENT(id));");
     }
@@ -368,7 +372,6 @@ int SqlEngine::searchEvent(int aConferenceId, const QHash<QString,QString> &aCol
 
     execQuery( db, query );
 
-    //TODO: retun number of rows from SEARCH_EVENT
     return 1;
 }