Software /
code /
prosody
Changeset
5969:0a3b8003ac9c
mod_storage_sql2: Expose the unique key argument, allowing arbitrary ids. Conflicting items are removed.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 25 Dec 2013 22:37:52 +0100 |
parents | 5968:e1e9f1411442 |
children | 5970:6a2c3293d4d7 |
files | plugins/mod_storage_sql2.lua |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua Wed Dec 25 15:28:55 2013 +0100 +++ b/plugins/mod_storage_sql2.lua Wed Dec 25 22:37:52 2013 +0100 @@ -216,11 +216,15 @@ local archive_store = {} archive_store.__index = archive_store -function archive_store:append(username, when, with, value) +function archive_store:append(username, key, when, with, value) + if value == nil then -- COMPAT early versions + when, with, value, key = key, when, with, value + end local user,store = username,self.store; return engine:transaction(function() - local key = uuid.generate(); + local key = key or uuid.generate(); 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);