diff options
author | Kim Alvefur <zash@zash.se> | 2013-07-10 12:01:23 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-07-10 12:01:23 +0200 |
commit | 01de781b7ba384214f74082cd61cc1cfd0db877c (patch) | |
tree | 018d201017388f4e8cf2e77c94ddac3937ce87de /plugins/mod_storage_sql2.lua | |
parent | 7cbbf991bc5f48bedaaa39926f524c90660dcd25 (diff) | |
download | prosody-01de781b7ba384214f74082cd61cc1cfd0db877c.tar.gz prosody-01de781b7ba384214f74082cd61cc1cfd0db877c.zip |
mod_storage_sql2: Make sure the user field is not NULL
Diffstat (limited to 'plugins/mod_storage_sql2.lua')
-rw-r--r-- | plugins/mod_storage_sql2.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index 382c0e23..24c08cf5 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -148,7 +148,7 @@ local user, store; 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 @@ local function keyval_store_get() 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 @@ local function keyval_store_set(data) 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 @@ local function keyval_store_set(data) 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; |