X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fpostgresqlstorage.cpp;h=fb8157acb1e477f51700b60aac3fa2b9a52b18f6;hb=cdc6091a2e02b84a48937cda287a0769ceb8726a;hp=48236bc04197b614a2e13a04fd8dbe241cb372b3;hpb=6a835281b265df6a06b7f41109ad2d449899fed0;p=quassel.git diff --git a/src/core/postgresqlstorage.cpp b/src/core/postgresqlstorage.cpp index 48236bc0..fb8157ac 100644 --- a/src/core/postgresqlstorage.cpp +++ b/src/core/postgresqlstorage.cpp @@ -22,7 +22,7 @@ #include -#include "logger.h" +#include "logmessage.h" #include "network.h" #include "quassel.h" @@ -1634,6 +1634,8 @@ bool PostgreSqlStorage::logMessage(Message &msg) } QVariantList params; + // PostgreSQL handles QDateTime()'s serialized format by default, and QDateTime() serializes + // to a 64-bit time compatible format by default. params << msg.timestamp() << msg.bufferInfo().bufferId().toInt() << msg.type() @@ -1718,6 +1720,8 @@ bool PostgreSqlStorage::logMessages(MessageList &msgs) for (int i = 0; i < msgs.count(); i++) { Message &msg = msgs[i]; QVariantList params; + // PostgreSQL handles QDateTime()'s serialized format by default, and QDateTime() serializes + // to a 64-bit time compatible format by default. params << msg.timestamp() << msg.bufferInfo().bufferId().toInt() << msg.type() @@ -1797,17 +1801,19 @@ QList PostgreSqlStorage::requestMsgs(UserId user, BufferId bufferId, Ms QDateTime timestamp; while (query.next()) { + // PostgreSQL returns date/time in ISO 8601 format, no 64-bit handling needed + // See https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT timestamp = query.value(1).toDateTime(); timestamp.setTimeSpec(Qt::UTC); Message msg(timestamp, bufferInfo, - (Message::Type)query.value(2).toUInt(), + (Message::Type)query.value(2).toInt(), query.value(8).toString(), query.value(4).toString(), query.value(5).toString(), query.value(6).toString(), query.value(7).toString(), - (Message::Flags)query.value(3).toUInt()); + (Message::Flags)query.value(3).toInt()); msg.setMsgId(query.value(0).toLongLong()); messagelist << msg; } @@ -1861,11 +1867,13 @@ QList PostgreSqlStorage::requestMsgsFiltered(UserId user, BufferId buff QDateTime timestamp; while (query.next()) { + // PostgreSQL returns date/time in ISO 8601 format, no 64-bit handling needed + // See https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT timestamp = query.value(1).toDateTime(); timestamp.setTimeSpec(Qt::UTC); Message msg(timestamp, bufferInfo, - (Message::Type)query.value(2).toUInt(), + (Message::Type)query.value(2).toInt(), query.value(8).toString(), query.value(4).toString(), query.value(5).toString(), @@ -1916,17 +1924,19 @@ QList PostgreSqlStorage::requestAllMsgs(UserId user, MsgId first, MsgId QDateTime timestamp; for (int i = 0; i < limit && query.next(); i++) { + // PostgreSQL returns date/time in ISO 8601 format, no 64-bit handling needed + // See https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT timestamp = query.value(2).toDateTime(); timestamp.setTimeSpec(Qt::UTC); Message msg(timestamp, bufferInfoHash[query.value(1).toInt()], - (Message::Type)query.value(3).toUInt(), + (Message::Type)query.value(3).toInt(), query.value(9).toString(), query.value(5).toString(), query.value(6).toString(), query.value(7).toString(), query.value(8).toString(), - (Message::Flags)query.value(4).toUInt()); + (Message::Flags)query.value(4).toInt()); msg.setMsgId(query.value(0).toLongLong()); messagelist << msg; } @@ -1978,11 +1988,13 @@ QList PostgreSqlStorage::requestAllMsgsFiltered(UserId user, MsgId firs QDateTime timestamp; for (int i = 0; i < limit && query.next(); i++) { + // PostgreSQL returns date/time in ISO 8601 format, no 64-bit handling needed + // See https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT timestamp = query.value(2).toDateTime(); timestamp.setTimeSpec(Qt::UTC); Message msg(timestamp, bufferInfoHash[query.value(1).toInt()], - (Message::Type)query.value(3).toUInt(), + (Message::Type)query.value(3).toInt(), query.value(9).toString(), query.value(5).toString(), query.value(6).toString(), @@ -2012,21 +2024,6 @@ QMap PostgreSqlStorage::getAllAuthUserNames() } -QString PostgreSqlStorage::getAuthUserName(UserId user) -{ - QString authusername; - QSqlQuery query(logDb()); - query.prepare(queryString("select_authusername")); - query.bindValue(":userid", user.toInt()); - safeExec(query); - watchQuery(query); - - if (query.first()) { - authusername = query.value(0).toString(); - } - return authusername; -} - // void PostgreSqlStorage::safeExec(QSqlQuery &query) { // qDebug() << "PostgreSqlStorage::safeExec"; // qDebug() << " executing:\n" << query.executedQuery();