Changeset

5890:544ca3d94596

util.sql: Rewrite MEDIUMTEXT to TEXT for drivers other than MySQL
author Kim Alvefur <zash@zash.se>
date Wed, 30 Oct 2013 10:24:35 +0100
parents 5889:ea6a3adb6a69
children 5891:b6a56934338c
files util/sql.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/sql.lua	Tue Oct 29 11:43:49 2013 +0100
+++ b/util/sql.lua	Wed Oct 30 10:24:35 2013 +0100
@@ -260,7 +260,11 @@
 function engine:_create_table(table)
 	local sql = "CREATE TABLE `"..table.name.."` (";
 	for i,col in ipairs(table.c) do
-		sql = sql.."`"..col.name.."` "..col.type;
+		local col_type = col.type;
+		if col_type == "MEDIUMTEXT" and self.params.driver ~= "MySQL" then
+			col_type = "TEXT"; -- MEDIUMTEXT is MySQL-specific
+		end
+		sql = sql.."`"..col.name.."` "..col_type;
 		if col.nullable == false then sql = sql.." NOT NULL"; end
 		if col.primary_key == true then sql = sql.." PRIMARY KEY"; end
 		if col.auto_increment == true then