I have a table containing 2 “uncommon” columns – order and like.
The table are replicated on two databases – MySQL and PostgreSQL.
And i need same app to connect to both databases and use same query on both:
PageModel.where("`like` >= ?", params[:liked])
This will work in MySQL only.
How to make ActiveRecord to quote the column name?
Something like:
PageModel.where("%s >= ?" % quote_column_name(:like), params[:liked])
I found a method that is useless for now – it just returns the column name without quote it.
http://www.rubydoc.info/docs/rails/3.2.8/ActiveRecord/ConnectionAdapters/Quoting:quote_column_name
Perhaps it is just a placeholder and there are another method that does this?
This depends from from one database adapter to the other. So basically, each adapter overrides this method with their own definition.
You’re interested in: