diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 17:49:06 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 17:49:06 -0700 |
commit | cae95fc02af1fff885dca4a29b2fd3711b809cab (patch) | |
tree | e177c3721d20596b4cc60e336b0999060e6e82a6 /spec/active_relation | |
parent | 2d3681bb3c9ed8136fc46857828b74ae39b6d990 (diff) | |
download | rails-cae95fc02af1fff885dca4a29b2fd3711b809cab.tar.gz rails-cae95fc02af1fff885dca4a29b2fd3711b809cab.tar.bz2 rails-cae95fc02af1fff885dca4a29b2fd3711b809cab.zip |
projections now support string passthrough
- there is a weird inconsistency in where bind is called on values; this needs to be resolved
Diffstat (limited to 'spec/active_relation')
-rw-r--r-- | spec/active_relation/unit/relations/projection_spec.rb | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/spec/active_relation/unit/relations/projection_spec.rb b/spec/active_relation/unit/relations/projection_spec.rb index 78766d3308..f58564840b 100644 --- a/spec/active_relation/unit/relations/projection_spec.rb +++ b/spec/active_relation/unit/relations/projection_spec.rb @@ -45,17 +45,37 @@ module ActiveRelation end describe '#to_sql' do - it "manufactures sql with a limited select clause" do - Projection.new(@relation, @attribute).to_sql.should be_like(" - SELECT `users`.`id` - FROM `users` - ") + describe 'when given an attribute' do + it "manufactures sql with a limited select clause" do + Projection.new(@relation, @attribute).to_sql.should be_like(" + SELECT `users`.`id` + FROM `users` + ") + end end - it "manufactures sql with value selects" do - Projection.new(@relation, Projection.new(@relation, @relation[:name])).to_sql.should be_like(" - SELECT (SELECT `users`.`name` FROM `users`) FROM `users` - ") + describe 'when given a relation' do + before do + @scalar_relation = Projection.new(@relation, @relation[:name]) + end + + it "manufactures sql with scalar selects" do + Projection.new(@relation, @scalar_relation).to_sql.should be_like(" + SELECT (SELECT `users`.`name` FROM `users`) FROM `users` + ") + end + end + + describe 'when given a string' do + before do + @string = "asdf" + end + + it "passes the string through to the select clause" do + Projection.new(@relation, @string).to_sql.should be_like(" + SELECT asdf FROM `users` + ") + end end end end |