Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add SelectManager#projections= method to overwrite projections

  • Loading branch information...
commit 88c91f7cdbe904c0a215a05be76ae120eacb24fb 1 parent 1609175
@jonleighton jonleighton authored
Showing with 13 additions and 0 deletions.
  1. +4 −0 lib/arel/select_manager.rb
  2. +9 −0 test/test_select_manager.rb
View
4 lib/arel/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|
View
9 test/test_select_manager.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.