Use null QVariant instead of "ALL" for select limit on psql
authorMichael Marley <michael@michaelmarley.com>
Mon, 1 Sep 2014 22:42:22 +0000 (18:42 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 14 Sep 2014 20:13:43 +0000 (22:13 +0200)
Using "ALL" as it was before was making PostgreSQL error out when
attempting to return backlog for Quasseldroid when Quasseldroid is
in "Unread messages per chat" mode.  According to
http://www.postgresql.org/docs/9.3/static/queries-limit.html,
LIMIT NULL is the same thing as having no LIMIT at all.  According
to http://qt-project.org/doc/qt-4.8/qsqlquery.html, NULL values
are bound in Qt SQL prepared statements by using a null QVariant.

src/core/postgresqlstorage.cpp

index 299e739..317abf9 100644 (file)
@@ -1516,7 +1516,7 @@ QList<Message> PostgreSqlStorage::requestMsgs(UserId user, BufferId bufferId, Ms
     if (limit != -1)
         params << limit;
     else
-        params << "ALL";
+        params << QVariant(QVariant::Int);
 
     QSqlQuery query = executePreparedQuery(queryName, params, db);