aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-10-29 11:43:49 +0100
committerKim Alvefur <zash@zash.se>2013-10-29 11:43:49 +0100
commit7b0320c5c674ee0eaa45fac9655202cd6a37fbd0 (patch)
tree673e46198004f4c4e738e62cd1806342161e6e32
parente20e010643e56b1f1a2a86146d09db84b170d1d6 (diff)
downloadprosody-7b0320c5c674ee0eaa45fac9655202cd6a37fbd0.tar.gz
prosody-7b0320c5c674ee0eaa45fac9655202cd6a37fbd0.zip
util.sql: Check what encoding SQLite3 uses
-rw-r--r--util/sql.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/sql.lua b/util/sql.lua
index 4e63bed7..8c870b64 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -290,8 +290,14 @@ function engine:_create_table(table)
return success;
end
function engine:set_encoding() -- to UTF-8
- if self.params.driver == "SQLite3" then return end
local driver = self.params.driver;
+ if driver == "SQLite3" then
+ return self:transaction(function()
+ if self:select"PRAGMA encoding;"()[1] == "UTF-8" then
+ self.charset = "utf8";
+ end
+ end);
+ end
local set_names_query = "SET NAMES '%s';"
local charset = "utf8";
if driver == "MySQL" then