Diff

plugins/mod_storage_sql.lua @ 7909:428d4abee723

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 20 Feb 2017 01:46:54 +0100
parent 7859:9eb13c14eaab
parent 7907:8e2446cdf6fa
child 8039:1f4bd8009961
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Wed Feb 15 23:05:03 2017 +0100
+++ b/plugins/mod_storage_sql.lua	Mon Feb 20 01:46:54 2017 +0100
@@ -187,7 +187,7 @@
 		when, with, value = value, when, with;
 	end
 	local user,store = username,self.store;
-	return engine:transaction(function()
+	local ok, key = engine:transaction(function()
 		if key then
 			engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key);
 		else
@@ -197,6 +197,8 @@
 		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);
+	if not ok then return ok, key; end
+	return key;
 end
 
 -- Helpers for building the WHERE clause