Tuesday, June 5, 2007

Electric Generators Ditect

Ruby on Rails applications with Ruby and Scribble Draw!

When building a model with a ruby \u200b\u200bon rails migration create a table in the database. The name of this table is equal to the pluralized form of the name model. In MySQL this migration will generate a sql statement of the form:

model_name_pluralized CREATE TABLE (`id` int (11) DEFAULT NULL auto_increment PRIMARY KEY, `created_on
 As you can see, the column names are quoted but not named in the table. If using as a model name in the singular form of a MySQL reserved word, the migration will generate a sql statement that will fail as  


Mysql:: Error: You have an error in your SQL syntax; check the manual That corresponds to your MySQL server version
for the right syntax to use near 'databases (`id` int (11) DEFAULT NULL auto_increment PRIMARY KEY , created_on `da`' at line 1: CREATE TABLE databases (`id` int (11) DEFAULT NULL auto_increment PRIMARY
KEY , `created_on` date DEFAULT NULL, `name` varchar (255)
DEFAULT NULL) ENGINE = InnoDB
  

Last week I read about Josh Susser
transparencies
(
Laying Tracks
) who encouraged me to write a patch for this problem.
Before writing anything looked if I could find something related. I found a similar ticket on the Rails trac
:

# 7850 [PATCH] Added missing backticks to mysql adapter

0 comments:

Post a Comment