aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
commit29988cfa70e9f0c0e8be63d3f6334a36fbe55ec3 (patch)
tree673e46198004f4c4e738e62cd1806342161e6e32 /util
parenta0d18144edee980a55660b4c9dfe34462f1e1d17 (diff)
downloadprosody-29988cfa70e9f0c0e8be63d3f6334a36fbe55ec3.tar.gz
prosody-29988cfa70e9f0c0e8be63d3f6334a36fbe55ec3.zip
util.sql: Check what encoding SQLite3 uses
Diffstat (limited to 'util')
-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