Comparison

plugins/mod_storage_sql2.lua @ 5996:e7efa9703a3f

mod_storage_sql2: Only attempt to delete conflicting items if an ID/key is given
author Kim Alvefur <zash@zash.se>
date Tue, 21 Jan 2014 01:51:13 +0100
parent 5995:aa7534a877fe
child 6013:918ab89cb68d
comparison
equal deleted inserted replaced
5995:aa7534a877fe 5996:e7efa9703a3f
220 if value == nil then -- COMPAT early versions 220 if value == nil then -- COMPAT early versions
221 when, with, value, key = key, when, with, value 221 when, with, value, key = key, when, with, value
222 end 222 end
223 local user,store = username,self.store; 223 local user,store = username,self.store;
224 return engine:transaction(function() 224 return engine:transaction(function()
225 local key = key or uuid.generate(); 225 if key then
226 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key);
227 else
228 key = uuid.generate();
229 end
226 local t, value = serialize(value); 230 local t, value = serialize(value);
227 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key);
228 engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value); 231 engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value);
229 return key; 232 return key;
230 end); 233 end);
231 end 234 end
232 235