1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add SelectManager#projections= method to overwrite projections

This commit is contained in:
Jon Leighton 2011-08-11 08:43:21 +01:00
parent 160917526a
commit 88c91f7cdb
2 changed files with 13 additions and 0 deletions

View file

@ -135,6 +135,10 @@ module Arel
self
end
def projections= projections
@ctx.projections = projections
end
def order *expr
# FIXME: We SHOULD NOT be converting these to SqlLiteral automatically
@ast.orders.concat expr.map { |x|

View file

@ -860,6 +860,15 @@ module Arel
end
end
describe 'projections=' do
it 'overwrites projections' do
manager = Arel::SelectManager.new Table.engine
manager.project Arel.sql('foo')
manager.projections = [Arel.sql('bar')]
manager.to_sql.must_be_like %{ SELECT bar }
end
end
describe 'take' do
it "knows take" do
table = Table.new :users