Forum: Ruby on Rails ror-generated sql syntax fails at 'where'.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
897a7fce94876f91d87ab4d19d8dde0a?d=identicon&s=25 Craig Spengler (craigb)
on 2006-03-21 22:57
I am working on my first Ruby-on-Rails project after completing
"cookbook" and "todo list" tutorials.

When "SAVE"ing a new record to a table, the "create" method throws SQL
error #42000 for:

  SELECT * FROM mailboxes WHERE (key = 'TEST')  LIMIT 1

but if i change syntax to fully-qualified column, the query tool is
happy with:

  SELECT * FROM mailboxes WHERE (mailboxes.key = 'TEST')  LIMIT 1

Unfortunately, as a newbie from the 4GL world, I haven't a clue how to
go about tracking the execution thread, and especially don't know if
this is a rails scaffold generation problem or if it is me.

Ruby v1.8.2, Rails 1.0.0, MySQL 5.0 all on WinXP(sorry!)-Pro fully

Many thanks in advance...
A332dcb1e051f733dc9a9bd78df3b560?d=identicon&s=25 Wes Garrison (Guest)
on 2006-03-21 23:10
(Received via mailing list)
'key' is a mysql reserved word.  Using a different column name would be
easy fix.  And yes, 'keys' is also a reserved word.

  -- Wes

On 3/21/06, craig spengler <> wrote:
> happy with:
> Many thanks in advance...
> --
> Posted via
> _______________________________________________
> Rails mailing list


    -- Wes
36df5a25b0f7e1a39826370b91497167?d=identicon&s=25 Charles Leeds (Guest)
on 2006-03-21 23:12
(Received via mailing list)
My guess may be that 'key' is a reserved word for whatever database you
are using.  Indeed it is definitely a reserved word in MySQL.  You will
need to rename the column 'mykey' or something else instead of 'key'.  I
have run into this myself and found this out the hard way.

Good luck!
897a7fce94876f91d87ab4d19d8dde0a?d=identicon&s=25 Craig Spengler (craigb)
on 2006-03-21 23:16
craig spengler wrote:
> Many thanks in advance...

Thanks, guys, i'll check it out right away.
This topic is locked and can not be replied to.