Comparison

util/sql.lua @ 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
parent 5889:ea6a3adb6a69
child 5910:a19b3646d5f0
comparison
equal deleted inserted replaced
5889:ea6a3adb6a69 5890:544ca3d94596
258 return self:execute(sql); 258 return self:execute(sql);
259 end 259 end
260 function engine:_create_table(table) 260 function engine:_create_table(table)
261 local sql = "CREATE TABLE `"..table.name.."` ("; 261 local sql = "CREATE TABLE `"..table.name.."` (";
262 for i,col in ipairs(table.c) do 262 for i,col in ipairs(table.c) do
263 sql = sql.."`"..col.name.."` "..col.type; 263 local col_type = col.type;
264 if col_type == "MEDIUMTEXT" and self.params.driver ~= "MySQL" then
265 col_type = "TEXT"; -- MEDIUMTEXT is MySQL-specific
266 end
267 sql = sql.."`"..col.name.."` "..col_type;
264 if col.nullable == false then sql = sql.." NOT NULL"; end 268 if col.nullable == false then sql = sql.." NOT NULL"; end
265 if col.primary_key == true then sql = sql.." PRIMARY KEY"; end 269 if col.primary_key == true then sql = sql.." PRIMARY KEY"; end
266 if col.auto_increment == true then 270 if col.auto_increment == true then
267 if self.params.driver == "PostgreSQL" then 271 if self.params.driver == "PostgreSQL" then
268 sql = sql.." SERIAL"; 272 sql = sql.." SERIAL";