Quote any references to id in raw sql

This is a fix for issue #397.  I ran the tests to make sure it doesn't break anything in rails 3.  I thought about how I could test this, but I couldn't think of a good way to do it without adding db specific sql to the schema.rb file.