diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-17 23:03:56 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-17 23:03:56 -0700 |
commit | 6e1450a2a646e416aaea003eff19b7703c563bed (patch) | |
tree | 5caa324b2d33d1b48d7e440bf36fc9fe8efa5405 /spec/arel | |
parent | 724a2684139342eb4613f78bfae723ef00911ff7 (diff) | |
download | rails-6e1450a2a646e416aaea003eff19b7703c563bed.tar.gz rails-6e1450a2a646e416aaea003eff19b7703c563bed.tar.bz2 rails-6e1450a2a646e416aaea003eff19b7703c563bed.zip |
performance enhancements
Diffstat (limited to 'spec/arel')
-rw-r--r-- | spec/arel/integration/joins/with_aggregations_spec.rb | 6 | ||||
-rw-r--r-- | spec/arel/unit/predicates/binary_spec.rb | 17 | ||||
-rw-r--r-- | spec/arel/unit/primitives/attribute_spec.rb | 11 | ||||
-rw-r--r-- | spec/arel/unit/relations/join_spec.rb | 10 |
4 files changed, 13 insertions, 31 deletions
diff --git a/spec/arel/integration/joins/with_aggregations_spec.rb b/spec/arel/integration/joins/with_aggregations_spec.rb index b9cb4acc31..655250f4f9 100644 --- a/spec/arel/integration/joins/with_aggregations_spec.rb +++ b/spec/arel/integration/joins/with_aggregations_spec.rb @@ -19,12 +19,6 @@ module Arel it '' do @relation1.join(@aggregation).on(@predicate)[@relation2[:user_id]].should_not be_nil end - - it 'it transforms aggregate expressions into attributes' do - join_with_aggregation = Join.new("INNER JOIN", @relation1, @aggregation, @predicate) - join_with_aggregation.attributes.should == - (@relation1.attributes + @aggregation.attributes).collect(&:to_attribute).collect { |a| a.bind(join_with_aggregation) } - end end describe '#to_sql' do diff --git a/spec/arel/unit/predicates/binary_spec.rb b/spec/arel/unit/predicates/binary_spec.rb index f39b37d913..2d6ef5d7e3 100644 --- a/spec/arel/unit/predicates/binary_spec.rb +++ b/spec/arel/unit/predicates/binary_spec.rb @@ -59,12 +59,21 @@ module Arel describe '#bind' do before do - @another_relation = Table.new(:photos) + @another_relation = @relation.alias end - it "descends" do - ConcreteBinary.new(@attribute1, @attribute2).bind(@another_relation). \ - should == ConcreteBinary.new(@attribute1.bind(@another_relation), @attribute2.bind(@another_relation)) + describe 'when both operands are attributes' do + it "manufactures an expression with the attributes bound to the relation" do + ConcreteBinary.new(@attribute1, @attribute2).bind(@another_relation). \ + should == ConcreteBinary.new(@another_relation[@attribute1], @another_relation[@attribute2]) + end + end + + describe 'when an operand is a value' do + it "manufactures an expression with unmodified values" do + ConcreteBinary.new(@attribute1, "asdf").bind(@another_relation). \ + should == ConcreteBinary.new(@another_relation[@attribute1], "asdf") + end end end end diff --git a/spec/arel/unit/primitives/attribute_spec.rb b/spec/arel/unit/primitives/attribute_spec.rb index 34665b5adf..890ac0e813 100644 --- a/spec/arel/unit/primitives/attribute_spec.rb +++ b/spec/arel/unit/primitives/attribute_spec.rb @@ -45,17 +45,6 @@ module Arel end describe Attribute::Congruence do - describe '#match?' do - it "obtains if the attributes are identical" do - @attribute.should be_match(@attribute) - end - - it "obtains if the attributes have an overlapping history" do - Attribute.new(@relation, :id, :ancestor => @attribute).should be_match(@attribute) - @attribute.should be_match(Attribute.new(@relation, :id, :ancestor => @attribute)) - end - end - describe '/' do before do @aliased_relation = @relation.alias diff --git a/spec/arel/unit/relations/join_spec.rb b/spec/arel/unit/relations/join_spec.rb index 347566e6ea..d128dd0560 100644 --- a/spec/arel/unit/relations/join_spec.rb +++ b/spec/arel/unit/relations/join_spec.rb @@ -55,16 +55,6 @@ module Arel INNER JOIN `photos` ON `users`.`id` = `photos`.`user_id` ") end - - it 'manufactures sql joining the two tables, with selects from the right table in the ON clause' do - Join.new("INNER JOIN", @relation1.select(@relation1[:id].eq(1)), - @relation2.select(@relation2[:id].eq(2)), @predicate).to_sql.should be_like(" - SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id` - FROM `users` - INNER JOIN `photos` ON `users`.`id` = `photos`.`user_id` AND `photos`.`id` = 2 - WHERE `users`.`id` = 1 - ") - end end describe 'when joining with a string' do |