On Tue, Oct 05, 2004 at 11:15:08PM +0900, jim / freeze.org wrote:
> David
> 
> I was tripped up for a period of time when Rails was complaining
> about an update to a table. The problem SQL query was:
> 
>     UPDATE
>       group = 'test'
>     WHEN id='1'
> 
> The problem is that (I guess) group is a keyword. So I fixed this by
> changing the name of the group field:
> 
>     UPDATE
>       grp = 'test'
>     WHEN id='1'
> 
> However, since rails seems to be catering to us 'dummies', it would be nice
> if rails had generated the following SQL query:
> 
> 
>     UPDATE
>       posts.group = 'test'
>     WHEN id='1'
> 
> where posts is the name of the table.
> This would have insulated me from having to avoid using
> 'bad' column names.
> 
> Does this sound like a reasonable change to make?


No the right solution would be to quote the column names:

    UPDATE
      `group` = 'test'
    WHEN `id`='1'

That ` is annoying on keyboards with dead keys though.

-- 
Thomas
beast / system-tnt.dk