mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
symbols work as sql literals
This commit is contained in:
parent
3e5186ffd8
commit
3aace4a471
2 changed files with 13 additions and 1 deletions
|
@ -96,7 +96,7 @@ module Arel
|
|||
# FIXME: converting these to SQLLiterals is probably not good, but
|
||||
# rails tests require it.
|
||||
@ctx.projections.concat projections.map { |x|
|
||||
String == x.class ? SqlLiteral.new(x) : x
|
||||
[Symbol, String].include?(x.class) ? SqlLiteral.new(x.to_s) : x
|
||||
}
|
||||
self
|
||||
end
|
||||
|
|
|
@ -37,6 +37,18 @@ module Arel
|
|||
|
||||
describe 'select manager' do
|
||||
describe 'backwards compatibility' do
|
||||
describe 'project' do
|
||||
it 'accepts symbols as sql literals' do
|
||||
table = Table.new :users
|
||||
manager = Arel::SelectManager.new Table.engine
|
||||
manager.project :id
|
||||
manager.from table
|
||||
manager.to_sql.should be_like %{
|
||||
SELECT id FROM "users"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'order' do
|
||||
it 'accepts symbols' do
|
||||
table = Table.new :users
|
||||
|
|
Loading…
Reference in a new issue