Diff

plugins/mod_storage_sql.lua @ 7305:c02e3d8f23fc

mod_storage_sql: Make sure all serialization errors are propagated
author Kim Alvefur <zash@zash.se>
date Mon, 21 Mar 2016 09:33:12 +0100
parent 7274:e0727512bb99
child 7359:a5a080c12c96
child 7751:168919a947ed
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Sat Mar 19 16:35:43 2016 +0100
+++ b/plugins/mod_storage_sql.lua	Mon Mar 21 09:33:12 2016 +0100
@@ -82,16 +82,14 @@
 		local extradata = {};
 		for key, value in pairs(data) do
 			if type(key) == "string" and key ~= "" then
-				local t, value = serialize(value);
-				assert(t, value);
+				local t, value = assert(serialize(value));
 				engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, key, t, value);
 			else
 				extradata[key] = value;
 			end
 		end
 		if next(extradata) ~= nil then
-			local t, extradata = serialize(extradata);
-			assert(t, extradata);
+			local t, extradata = assert(serialize(extradata));
 			engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, "", t, extradata);
 		end
 	end
@@ -197,7 +195,7 @@
 		else
 			key = uuid.generate();
 		end
-		local t, value = serialize(value);
+		local t, value = assert(serialize(value));
 		engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value);
 		return key;
 	end);