Is there a trick required to make Rails recognize constants in a SQL select statement? For example, the following SQL statement is valid:
SELECT id, name, 1 AS constant FROM table_name
And I would expect the results to have three columns returned: id, name and constant. The value in the constant column would always be 1.
However, in Rails if I try to do the same thing the constant column gets dropped using Model.find_by_sql:
TableName.find_by_sql("SELECT id, name, 1 AS constant FROM table_name")
or
ActiveRecord::Base.connection.execute("SELECT id, name, 1 AS constant FROM table_name")
Is this is a bug or a known limitation in Rails 4.0 or if there is another way to do this that I'm not trying?