gdavis
gdavis

Reputation: 2585

Ruby error with simple ActiveRecord.find

I'm writing some rake taks to find objects with a simple find method as follows:

skill = Mastery.find(:first, :conditions =>  [ "tree = ? AND tier = ? AND column = ?",
              i.to_s,
              row_index.to_s,
              col_index.to_s
            ])

This works fine locally. However, when I deploy to my production environment the server fails and responds with this error:

Mysql2::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 'column = '1') LIMIT 1' at line 1: SELECT  `masteries`.* FROM `masteries`  WHERE (tree = '1' AND tier = '1' AND column = '1') LIMIT 1

I'm using the mysql2 gem in my rails app. Any idea what I can do to fix this?

Upvotes: 0

Views: 37

Answers (1)

DRobinson
DRobinson

Reputation: 4471

Is it possible that "column" is a reserved word on that particular version of MySQL? http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

It could be the case that MySQL is giving an error because you're using a reserved word as a column name.

Upvotes: 2

Related Questions