diff options
author | Kim Alvefur <zash@zash.se> | 2013-10-28 22:07:16 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-10-28 22:07:16 +0100 |
commit | acefadc54b01fb4fe76fc9418b44798d5b09c8c6 (patch) | |
tree | 4648b821daf0aa3a8b8edacae44339d3fdd6c534 /util | |
parent | 6c411a5f8e8d1bf4d3aec0a9899eed58b57d4839 (diff) | |
download | prosody-acefadc54b01fb4fe76fc9418b44798d5b09c8c6.tar.gz prosody-acefadc54b01fb4fe76fc9418b44798d5b09c8c6.zip |
mod_storage_sql2, util.sql: Move code for setting encoding to util.sql
Diffstat (limited to 'util')
-rw-r--r-- | util/sql.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/util/sql.lua b/util/sql.lua index b8c16e27..972940f7 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -276,6 +276,17 @@ function engine:_create_table(table) end return success; end +function engine:set_encoding() -- to UTF-8 + if self.params.driver == "SQLite3" then return end + local set_names_query = "SET NAMES 'utf8';"; + if self.params.driver == "MySQL" then + set_names_query = set_names_query:gsub(";$", " COLLATE 'utf8_bin';"); + end + local success,err = engine:transaction(function() return engine:execute(set_names_query); end); + if not success then + log("error", "Failed to set database connection encoding to UTF8: %s", err); + end +end local engine_mt = { __index = engine }; local function db2uri(params) |