Comparison

util/sql.lua @ 5889:ea6a3adb6a69

util.sql: Check what encoding SQLite3 uses
author Kim Alvefur <zash@zash.se>
date Tue, 29 Oct 2013 11:43:49 +0100
parent 5888:f3e408ae59a6
child 5890:544ca3d94596
comparison
equal deleted inserted replaced
5888:f3e408ae59a6 5889:ea6a3adb6a69
288 end 288 end
289 end 289 end
290 return success; 290 return success;
291 end 291 end
292 function engine:set_encoding() -- to UTF-8 292 function engine:set_encoding() -- to UTF-8
293 if self.params.driver == "SQLite3" then return end
294 local driver = self.params.driver; 293 local driver = self.params.driver;
294 if driver == "SQLite3" then
295 return self:transaction(function()
296 if self:select"PRAGMA encoding;"()[1] == "UTF-8" then
297 self.charset = "utf8";
298 end
299 end);
300 end
295 local set_names_query = "SET NAMES '%s';" 301 local set_names_query = "SET NAMES '%s';"
296 local charset = "utf8"; 302 local charset = "utf8";
297 if driver == "MySQL" then 303 if driver == "MySQL" then
298 set_names_query = set_names_query:gsub(";$", " COLLATE 'utf8_bin';"); 304 set_names_query = set_names_query:gsub(";$", " COLLATE 'utf8_bin';");
299 local ok, charsets = self:transaction(function() 305 local ok, charsets = self:transaction(function()