From d6f06fa146cb0e7d6baee40a3e7037cdb4f0ab6a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 19 May 2015 18:21:23 +0200 Subject: mod_storage_sql2: Include 'with' field from iterator like some 3rd party archive-capable storage modules --- plugins/mod_storage_sql2.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index d5e0494f..c02ad42c 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -281,7 +281,7 @@ function archive_store:find(username, query) local user,store = username,self.store; local total; local ok, result = engine:transaction(function() - local sql_query = "SELECT `key`, `type`, `value`, `when` FROM `prosodyarchive` WHERE %s ORDER BY `sort_id` %s%s;"; + local sql_query = "SELECT `key`, `type`, `value`, `when`, `with` FROM `prosodyarchive` WHERE %s ORDER BY `sort_id` %s%s;"; local args = { host, user or "", store, }; local where = { "`host` = ?", "`user` = ?", "`store` = ?", }; @@ -313,7 +313,7 @@ function archive_store:find(username, query) return function() local row = result(); if row ~= nil then - return row[1], deserialize(row[2], row[3]), row[4]; + return row[1], deserialize(row[2], row[3]), row[4], row[5]; end end, total; end -- cgit v1.2.3 From 27a5c819f44a16fd8f6dfae24ed53dcc4366ff67 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 19 May 2015 18:24:09 +0200 Subject: mod_storage_sql2: Change order of arguments to :append to be the same as return values from :find iterator --- plugins/mod_storage_sql2.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index c02ad42c..aab37697 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -216,9 +216,9 @@ end local archive_store = {} archive_store.__index = archive_store -function archive_store:append(username, key, when, with, value) - if value == nil then -- COMPAT early versions - when, with, value, key = key, when, with, value +function archive_store:append(username, key, value, when, with) + if type(when) ~= "number" then + value, when, with = when, with, value; end local user,store = username,self.store; return engine:transaction(function() -- cgit v1.2.3 From 720a6a5deb52fbc3944bb7a9a5f46a3dd33f46f8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 19 May 2015 18:24:53 +0200 Subject: mod_storage_sql2: Add a 'caps' table for indicating support for optional features --- plugins/mod_storage_sql2.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index aab37697..21299f33 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -215,6 +215,9 @@ function keyval_store:users() end local archive_store = {} +archive_store.caps = { + total = true; +}; archive_store.__index = archive_store function archive_store:append(username, key, value, when, with) if type(when) ~= "number" then -- cgit v1.2.3 From f4b4f1020ae91754d915d296749510031e7c784c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 21 May 2015 12:11:08 +0200 Subject: mod_storage_sql2: Fix argument compat thing from 41725f3df3cc, it was backwards --- plugins/mod_storage_sql2.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index 21299f33..e15668af 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -221,7 +221,7 @@ archive_store.caps = { archive_store.__index = archive_store function archive_store:append(username, key, value, when, with) if type(when) ~= "number" then - value, when, with = when, with, value; + when, with, value = value, when, with; end local user,store = username,self.store; return engine:transaction(function() -- cgit v1.2.3