Software /
code /
prosody
Changeset
5732:4aa1d6f5083a
mod_storage_sql2: Make sure the user field is not NULL
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 10 Jul 2013 12:01:23 +0200 |
parents | 5731:902927f1c96f |
children | 5733:aeeced7b0149 |
files | plugins/mod_storage_sql2.lua |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua Wed Jul 10 07:47:54 2013 +0200 +++ b/plugins/mod_storage_sql2.lua Wed Jul 10 12:01:23 2013 +0200 @@ -148,7 +148,7 @@ local function keyval_store_get() local haveany; local result = {}; - for row in engine:select("SELECT `key`,`type`,`value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=?", host, user, store) do + for row in engine:select("SELECT `key`,`type`,`value` FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=?", host, user or "", store) do haveany = true; local k = row[1]; local v = deserialize(row[2], row[3]); @@ -165,7 +165,7 @@ end end local function keyval_store_set(data) - engine:delete("DELETE FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=?", host, user, store); + engine:delete("DELETE FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=?", host, user or "", store); if data and next(data) ~= nil then local extradata = {}; @@ -173,7 +173,7 @@ if type(key) == "string" and key ~= "" then local t, value = serialize(value); assert(t, value); - engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user, store, key, t, value); + engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, key, t, value); else extradata[key] = value; end @@ -181,7 +181,7 @@ if next(extradata) ~= nil then local t, extradata = serialize(extradata); assert(t, extradata); - engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user, store, "", t, extradata); + engine:insert("INSERT INTO `prosody` (`host`,`user`,`store`,`key`,`type`,`value`) VALUES (?,?,?,?,?,?)", host, user or "", store, "", t, extradata); end end return true;