I was using the scaffold generator to work on a new model that I initially named "field" (as in a playing field), and I got the following error: ActiveRecord::StatementInvalid in Fields#index #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''fields'' at line 1: SELECT * FROM fields I tried this myself directly, and I realized that it was a reserved word issue and that the in order to work, the statement had to be "SELECT * FROM `fields`" Now, should the SQL that ActiveRecord generates have the backticks around the table names, or is that a MySQL-specific thing?
I wonder why you need to quote "fields?" "Fields" is not a reserved word, at least according to: http://dev.mysql.com/doc/mysql/en/reserved-words.html On Sun, 20 Feb 2005 18:14:20 -0500, Jon Bauman <baumanj-63aXycvo3TyHXe+LvDLADg@public.gmane.org> wrote:> I was using the scaffold generator to work on a new model that I > initially named "field" (as in a playing field), and I got the > following error: > > ActiveRecord::StatementInvalid in Fields#index > > #42000You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use > near ''fields'' at line 1: SELECT * FROM fields > > I tried this myself directly, and I realized that it was a reserved > word issue and that the in order to work, the statement had to be > > "SELECT * FROM `fields`" > > Now, should the SQL that ActiveRecord generates have the backticks > around the table names, or is that a MySQL-specific thing? > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Sinclair ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org
On 21-Feb-2005, at 13:01, Ben Sinclair wrote:> I wonder why you need to quote "fields?" "Fields" is not a reserved > word, at least according to: > http://dev.mysql.com/doc/mysql/en/reserved-words.html > > > On Sun, 20 Feb 2005 18:14:20 -0500, Jon Bauman <baumanj-63aXycvo3TyHXe+LvDLADg@public.gmane.org> > wrote: >> I was using the scaffold generator to work on a new model that I >> initially named "field" (as in a playing field), and I got the >> following error: >>Although FIELDS isn''t listed as a reserved word, SHOW FIELDS is a synonym for SHOW COLUMNS. It''s all over your log/*.log too. I guess that one fell through the cracks. Regards, JJ
On Feb 21, 2005, at 1:16 PM, John Johnson wrote:> On 21-Feb-2005, at 13:01, Ben Sinclair wrote: >> I wonder why you need to quote "fields?" "Fields" is not a reserved >> word, at least according to: >> http://dev.mysql.com/doc/mysql/en/reserved-words.html >> On Sun, 20 Feb 2005 18:14:20 -0500, Jon Bauman <baumanj-63aXycvo3TyHXe+LvDLADg@public.gmane.org> >> wrote: >>> I was using the scaffold generator to work on a new model that I >>> initially named "field" (as in a playing field), and I got the >>> following error: > Although FIELDS isn''t listed as a reserved word, > SHOW FIELDS is a synonym for SHOW COLUMNS. > It''s all over your log/*.log too. > > I guess that one fell through the cracks.So, is enclosing identifier names such as tables and columns in backticks MySQL specific? If not, it seems that it would be best if ActiveRecord did so. Should I submit a ticket?