don't rely on implicit typecast when using postgres
[quassel.git] / src / core / postgresqlstorage.cpp
index bd1e089..5f24513 100644 (file)
@@ -79,12 +79,10 @@ QVariantMap PostgreSqlStorage::setupDefaults() const {
   return map;
 }
 
-bool PostgreSqlStorage::setup(const QVariantMap &settings) {
-  bool success = AbstractSqlStorage::setup(settings);
-  if(success) {
-    logDb().exec(QString("ALTER USER %1 SET standard_conforming_strings TO on").arg(userName()));
-  }
-  return success;
+void PostgreSqlStorage::initDbSession(QSqlDatabase &db) {
+  // this blows... but unfortunately Qt's PG driver forces us to this...
+  db.exec("set standard_conforming_strings = off");
+  db.exec("set escape_string_warning = off");
 }
 
 void PostgreSqlStorage::setConnectionProperties(const QVariantMap &properties) {
@@ -908,6 +906,8 @@ BufferInfo PostgreSqlStorage::bufferInfo(UserId user, const NetworkId &networkId
   createQuery.bindValue(":buffertype", (int)type);
   createQuery.bindValue(":buffername", buffer);
   createQuery.bindValue(":buffercname", buffer.toLower());
+  createQuery.bindValue(":joined", type & BufferInfo::ChannelBuffer ? true : false);
+
   safeExec(createQuery);
 
   if(createQuery.lastError().isValid()) {
@@ -1067,7 +1067,7 @@ bool PostgreSqlStorage::mergeBuffersPermanently(const UserId &user, const Buffer
   }
 
   QSqlQuery checkQuery(db);
-  checkQuery.prepare("SELECT count(*) FROM buffer"
+  checkQuery.prepare("SELECT count(*) FROM buffer "
                     "WHERE userid = :userid AND bufferid IN (:buffer1, :buffer2)");
   checkQuery.bindValue(":userid", user.toInt());
   checkQuery.bindValue(":buffer1", bufferId1.toInt());