Software /
code /
prosody
Diff
plugins/mod_storage_sql2.lua @ 5883:39b187e7e892
mod_storage_sql2, util.sql: Move code for setting encoding to util.sql
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 28 Oct 2013 22:07:16 +0100 |
parent | 5882:fbba2997aabb |
child | 5884:9cb81a17ae23 |
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua Mon Oct 28 21:37:30 2013 +0100 +++ b/plugins/mod_storage_sql2.lua Mon Oct 28 22:07:16 2013 +0100 @@ -82,17 +82,7 @@ ProsodyArchiveTable:create(engine); end); end -local function set_encoding() - if params.driver == "SQLite3" then return end - local set_names_query = "SET NAMES 'utf8';"; - if 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 - module:log("error", "Failed to set database connection encoding to UTF8: %s", err); - end -end + local function upgrade_table() if params.driver == "MySQL" then local success,err = engine:transaction(function() @@ -146,7 +136,7 @@ --local dburi = db2uri(params); engine = mod_sql:create_engine(params); - set_encoding(); + engine:set_encoding(); -- Automatically create table, ignore failure (table probably already exists) create_table();