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 patched. Many thanks in advance... -- Posted via http://www.ruby-forum.com/.
''key'' is a mysql reserved word. Using a different column name would be an easy fix. And yes, ''keys'' is also a reserved word. -- Wes On 3/21/06, craig spengler <craig.rubyforum@bugpak.com> wrote:> > 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 > patched. > > Many thanks in advance... > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -- Wes -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060321/bcacc971/attachment-0001.html
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! http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html craig spengler wrote:> 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 > patched. > > Many thanks in advance... > >
Reasonably Related Threads
- firewalld / iptables / nftables
- [Bug 1348] New: v1.8.2 iptables-nft-restore incorrectly handles multiple replace commands
- Fastest learning path to RoR
- [Patch] HttpServer.port reports the bound port
- [Bug 1335] New: iptables-restore will crash if -6 rules are present