util.sql: Check what encoding SQLite3 uses
authorKim Alvefur <zash@zash.se>
Tue, 29 Oct 2013 11:43:49 +0100
changeset 5889 ea6a3adb6a69
parent 5888 f3e408ae59a6
child 5890 544ca3d94596
util.sql: Check what encoding SQLite3 uses
util/sql.lua
--- a/util/sql.lua	Tue Oct 29 11:42:55 2013 +0100
+++ b/util/sql.lua	Tue Oct 29 11:43:49 2013 +0100
@@ -290,8 +290,14 @@
 	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