changeset 36:2b83559b78db

BUGFIX: batch inserts inserted empty values. BUGFIX: cutoff limit was not observed at cutoff, but cutoff + 1
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Fri, 07 Sep 2012 13:06:10 +0200
parents 769f43c4c5d0
children c52a0627337c
files DBCache.hpp
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/DBCache.hpp	Fri Sep 07 11:46:46 2012 +0200
+++ b/DBCache.hpp	Fri Sep 07 13:06:10 2012 +0200
@@ -18,7 +18,6 @@
 #include "Exception/SQLException.hpp"
 #include "Exception/IOException.hpp"
 
-
 template<typename T>
 struct SQLGenerator
 {
@@ -154,9 +153,9 @@
     query.bindValue(valueString(prefix), value);
   }
 
-  static void bindValues(QSqlQuery& query, const QVariantList& value, const QString& prefix = QString())
+  static void bindValues(QSqlQuery& query, const QVariantList& values, const QString& prefix = QString())
   {
-    query.bindValue(valueString(prefix), value);
+    query.bindValue(valueString(prefix), values);
   }
 
   static void bindValues(QSqlQuery& query, const QList<UniqueString>& values, const QString& prefix = QString())
@@ -289,7 +288,7 @@
       values << *memoryMap.value(key);
     }
     SQLGenerator<Value>::bindValues(insertQuery, values, "value");
-    if (!insertQuery.exec()) {
+    if (!insertQuery.execBatch()) {
       throw SQLException(insertQuery);
     }
     insertQuery.finish();
@@ -337,7 +336,7 @@
     if (memoryMapped) {
       memoryMap.insert(key, value);
       unsyncedKeys.append(key);
-      if (unsyncedKeys.size() > 1024) {
+      if (unsyncedKeys.size() >= 1024) {
 	syncInsert();
       }
     }