Fixed in edge rails: table name quoting

October 16, 2007 code 1 min read

One of more annoying ActiveRecord bugs has finally been fixed in edge rails after 2 years. Table names in SQL queries are now properly escaped.

On nearly every project it seems I end up having a table name that doesn’t work in either MySQL or sqlite. While they usually are SQL reserved words, most databases allow you to use reserved words if they’re properly quoted.

The following, which doesn’t work in MySQL:


will now be:

DELETE FROM `values`;
This content is open source. Suggest Improvements.


avatar of Brandon Keepers I am Brandon Keepers, and I work at GitHub on making Open Source more approachable, effective, and ubiquitous. I tend to think like an engineer, work like an artist, dream like an astronaut, love like a human, and sleep like a baby.