Software /
code /
prosody
Changeset
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 |
parents | 5995:aa7534a877fe |
children | 6000:0f6399c86c10 |
files | plugins/mod_storage_sql2.lua |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua Tue Jan 21 00:51:31 2014 +0100 +++ b/plugins/mod_storage_sql2.lua Tue Jan 21 01:51:13 2014 +0100 @@ -222,9 +222,12 @@ end local user,store = username,self.store; return engine:transaction(function() - local key = key or uuid.generate(); + if key then + engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); + else + key = uuid.generate(); + end local t, value = serialize(value); - engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", host, user or "", store, key); 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);