Merge 0.10->trunk
authorKim Alvefur <zash@zash.se>
Tue, 19 May 2015 23:23:44 +0200
changeset 6730 eb9c842b80fa
parent 6726 fb25dce69d41 (current diff)
parent 6729 e6e80ec50030 (diff)
child 6732 daa5c83b2879
Merge 0.10->trunk
plugins/mod_storage_sql2.lua
--- a/plugins/mod_storage_sql2.lua	Tue May 19 16:33:18 2015 +0100
+++ b/plugins/mod_storage_sql2.lua	Tue May 19 23:23:44 2015 +0200
@@ -248,10 +248,13 @@
 end
 
 local archive_store = {}
+archive_store.caps = {
+	total = true;
+};
 archive_store.__index = archive_store
-function archive_store:append(username, key, when, with, value)
-	if value == nil then -- COMPAT early versions
-		when, with, value, key = key, when, with, value
+function archive_store:append(username, key, value, when, with)
+	if type(when) ~= "number" then
+		value, when, with = when, with, value;
 	end
 	local user,store = username,self.store;
 	return engine:transaction(function()
@@ -314,7 +317,7 @@
 	local user,store = username,self.store;
 	local total;
 	local ok, result = engine:transaction(function()
-		local sql_query = "SELECT `key`, `type`, `value`, `when` FROM `prosodyarchive` WHERE %s ORDER BY `sort_id` %s%s;";
+		local sql_query = "SELECT `key`, `type`, `value`, `when`, `with` FROM `prosodyarchive` WHERE %s ORDER BY `sort_id` %s%s;";
 		local args = { host, user or "", store, };
 		local where = { "`host` = ?", "`user` = ?", "`store` = ?", };
 
@@ -346,7 +349,7 @@
 	return function()
 		local row = result();
 		if row ~= nil then
-			return row[1], deserialize(row[2], row[3]), row[4];
+			return row[1], deserialize(row[2], row[3]), row[4], row[5];
 		end
 	end, total;
 end