From 7354602f6f11db09f7e58a833dcf9cb141abf50a Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Sat, 16 Feb 2008 20:55:29 -0800 Subject: adding support for scalar selects --- spec/active_relation/predicates/binary_spec.rb | 2 +- spec/active_relation/relations/projection_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/active_relation/predicates/binary_spec.rb b/spec/active_relation/predicates/binary_spec.rb index 127375f24c..89a40d2bf3 100644 --- a/spec/active_relation/predicates/binary_spec.rb +++ b/spec/active_relation/predicates/binary_spec.rb @@ -41,7 +41,7 @@ module ActiveRelation end describe '#to_sql' do - it 'manufactures correct sql' do + it 'manufactures sql with a binary operation' do ConcreteBinary.new(@attribute1, @attribute2).to_sql.should be_like(""" `users`.`id` <=> `photos`.`id` """) diff --git a/spec/active_relation/relations/projection_spec.rb b/spec/active_relation/relations/projection_spec.rb index 739a16c8ef..2bc4ed1d6e 100644 --- a/spec/active_relation/relations/projection_spec.rb +++ b/spec/active_relation/relations/projection_spec.rb @@ -44,6 +44,12 @@ module ActiveRelation FROM `users` """) end + + it "manufactures sql with scalar selects" do + Projection.new(@relation, Projection.new(@relation, @relation[:name])).to_sql.should be_like(""" + SELECT (SELECT `users`.`name` FROM `users`) FROM `users` + """) + end end end end \ No newline at end of file -- cgit v1.2.3