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:
parent
160917526a
commit
88c91f7cdb
2 changed files with 13 additions and 0 deletions
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue