Forum: Ruby ActiveRecord automatic quoted identifiers

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E21a7ccb98dc7a3a7698e43bc0b56bf3?d=identicon&s=25 Jeremy (Guest)
on 2006-01-25 06:14
(Received via mailing list)
Is there a way to tell ActiveRecord to automatically quote all
table/column/etc. identifiers in the SQL that it generates?  I just
upgraded to MySql 5 and we have a database table named "Release"...
This is a new reserved word.  Bummer.

I want ActiveRecord to automatically generate SQL like:

SELECT `name` FROM `Release`
instead of:
SELECT name FROM Release

I can use ActiveRecord::Base#set_table_name to deal with this
particular case but it seems like a bit of a hack.  Anyone know if
there's a global setting for this in database.yml or something?

Jeremy
7264fb16beeea92b89bb42023738259d?d=identicon&s=25 Christian Neukirchen (Guest)
on 2006-01-25 15:40
(Received via mailing list)
"Jeremy" <jeremy.borden@gmail.com> writes:

>
> I can use ActiveRecord::Base#set_table_name to deal with this
> particular case but it seems like a bit of a hack.  Anyone know if
> there's a global setting for this in database.yml or something?

+1.  I was once bitten by using the PostgreSQL reserved word "user" as
column name, which is the *only* function that can be called without
parentheses.  *sigh*.
This topic is locked and can not be replied to.