diff options
author | Matthew Wild <mwild1@gmail.com> | 2015-07-08 15:06:20 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2015-07-08 15:06:20 +0100 |
commit | eeb1c1be540af288105580944eb3664b20abfd21 (patch) | |
tree | 4cbab166ddd32722595f72045d2fc2de9b409fb1 /util/sql.lua | |
parent | 7a4ec3c57c8e38c49f6527ea00abea9a5dd3ada6 (diff) | |
download | prosody-eeb1c1be540af288105580944eb3664b20abfd21.tar.gz prosody-eeb1c1be540af288105580944eb3664b20abfd21.zip |
util.sql: Use appropriate collation for the chosen character set - fixes MySQL silently ignoring our SET NAMES command when we use utf8mb4
Diffstat (limited to 'util/sql.lua')
-rw-r--r-- | util/sql.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util/sql.lua b/util/sql.lua index 562ac709..fc1191f9 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -268,12 +268,12 @@ function engine:set_encoding() -- to UTF-8 local set_names_query = "SET NAMES '%s';" local charset = "utf8"; if driver == "MySQL" then - set_names_query = set_names_query:gsub(";$", " COLLATE 'utf8_bin';"); local ok, charsets = self:transaction(function() return self:select"SELECT `CHARACTER_SET_NAME` FROM `information_schema`.`CHARACTER_SETS` WHERE `CHARACTER_SET_NAME` LIKE 'utf8%' ORDER BY MAXLEN DESC LIMIT 1;"; end); local row = ok and charsets(); charset = row and row[1] or charset; + set_names_query = set_names_query:gsub(";$", (" COLLATE '%s';"):format(charset.."_bin")); end self.charset = charset; return self:transaction(function() return self:execute(set_names_query:format(charset)); end); |