Mercurial > prosody-hg
diff plugins/mod_storage_sql2.lua @ 6001:34f43c8167e5
Merge 0.10->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 21 Jan 2014 03:26:04 +0000 |
| parents | e7efa9703a3f |
| children | 918ab89cb68d |
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua Sat Jan 18 18:46:31 2014 +0000 +++ b/plugins/mod_storage_sql2.lua Tue Jan 21 03:26:04 2014 +0000 @@ -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);
