Permalink
Browse files

Add SelectManager#projections= method to overwrite projections

  • Loading branch information...
jonleighton committed Aug 11, 2011
1 parent 1609175 commit 88c91f7cdbe904c0a215a05be76ae120eacb24fb
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/arel/select_manager.rb
  2. +9 −0 test/test_select_manager.rb
@@ -135,6 +135,10 @@ def project *projections
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 @@ def test_join_sources
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

0 comments on commit 88c91f7

Please sign in to comment.