diff options
Diffstat (limited to 'spec/arel')
-rw-r--r-- | spec/arel/integration/joins/with_adjacency_spec.rb | 20 | ||||
-rw-r--r-- | spec/arel/integration/joins/with_aggregations_spec.rb | 10 | ||||
-rw-r--r-- | spec/arel/integration/joins/with_compounds_spec.rb | 12 | ||||
-rw-r--r-- | spec/arel/unit/primitives/attribute_spec.rb | 2 | ||||
-rw-r--r-- | spec/arel/unit/primitives/expression_spec.rb | 2 | ||||
-rw-r--r-- | spec/arel/unit/relations/alias_spec.rb | 2 | ||||
-rw-r--r-- | spec/arel/unit/relations/deletion_spec.rb | 4 | ||||
-rw-r--r-- | spec/arel/unit/relations/relation_spec.rb | 10 | ||||
-rw-r--r-- | spec/arel/unit/relations/update_spec.rb | 6 | ||||
-rw-r--r-- | spec/arel/unit/relations/where_spec.rb (renamed from spec/arel/unit/relations/selection_spec.rb) | 12 |
10 files changed, 40 insertions, 40 deletions
diff --git a/spec/arel/integration/joins/with_adjacency_spec.rb b/spec/arel/integration/joins/with_adjacency_spec.rb index 222303977f..2fb5895a87 100644 --- a/spec/arel/integration/joins/with_adjacency_spec.rb +++ b/spec/arel/integration/joins/with_adjacency_spec.rb @@ -19,10 +19,10 @@ module Arel ") end - describe 'when joining with a selection on the same relation' do + describe 'when joining with a where on the same relation' do it 'manufactures sql aliasing the tables properly' do @relation1 \ - .join(@relation2.select(@relation2[:id].eq(1))) \ + .join(@relation2.where(@relation2[:id].eq(1))) \ .on(@predicate) \ .to_sql.should be_like(" SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name` @@ -32,9 +32,9 @@ module Arel ") end - describe 'when the selection occurs before the alias' do + describe 'when the where occurs before the alias' do it 'manufactures sql aliasing the predicates properly' do - relation2 = @relation1.select(@relation1[:id].eq(1)).alias + relation2 = @relation1.where(@relation1[:id].eq(1)).alias @relation1 \ .join(relation2) \ .on(relation2[:id].eq(@relation1[:id])) \ @@ -100,7 +100,7 @@ module Arel describe 'when both relations are compound and only one is an alias' do it 'disambiguates the relation that serves as the ancestor to the attribute' do - compound1 = @relation1.select(@predicate) + compound1 = @relation1.where(@predicate) compound2 = compound1.alias compound1 \ .join(compound2) \ @@ -112,8 +112,8 @@ module Arel describe 'when the left relation is extremely compound' do it 'disambiguates the relation that serves as the ancestor to the attribute' do @relation1 \ - .select(@predicate) \ - .select(@predicate) \ + .where(@predicate) \ + .where(@predicate) \ .join(@relation2) \ .on(@predicate) \ .should disambiguate_attributes(@relation1[:id], @relation2[:id]) @@ -125,9 +125,9 @@ module Arel @relation1 \ .join( \ @relation2 \ - .select(@predicate) \ - .select(@predicate) \ - .select(@predicate)) \ + .where(@predicate) \ + .where(@predicate) \ + .where(@predicate)) \ .on(@predicate) \ .should disambiguate_attributes(@relation1[:id], @relation2[:id]) end diff --git a/spec/arel/integration/joins/with_aggregations_spec.rb b/spec/arel/integration/joins/with_aggregations_spec.rb index ab904d103d..b4861b0c53 100644 --- a/spec/arel/integration/joins/with_aggregations_spec.rb +++ b/spec/arel/integration/joins/with_aggregations_spec.rb @@ -50,10 +50,10 @@ module Arel end end - describe 'when the aggration has a selection' do + describe 'when the aggration has a where' do describe 'with the aggregation on the left' do - it "manufactures sql keeping selects on the aggregation within the derived table" do - @relation1.join(@aggregation.select(@aggregation[:user_id].eq(1))).on(@predicate).to_sql.should be_like(" + it "manufactures sql keeping wheres on the aggregation within the derived table" do + @relation1.join(@aggregation.where(@aggregation[:user_id].eq(1))).on(@predicate).to_sql.should be_like(" SELECT `users`.`id`, `users`.`name`, `photos_aggregation`.`user_id`, `photos_aggregation`.`cnt` FROM `users` INNER JOIN (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` WHERE `photos`.`user_id` = 1 GROUP BY `photos`.`user_id`) AS `photos_aggregation` @@ -63,8 +63,8 @@ module Arel end describe 'with the aggregation on the right' do - it "manufactures sql keeping selects on the aggregation within the derived table" do - @aggregation.select(@aggregation[:user_id].eq(1)).join(@relation1).on(@predicate).to_sql.should be_like(" + it "manufactures sql keeping wheres on the aggregation within the derived table" do + @aggregation.where(@aggregation[:user_id].eq(1)).join(@relation1).on(@predicate).to_sql.should be_like(" SELECT `photos_aggregation`.`user_id`, `photos_aggregation`.`cnt`, `users`.`id`, `users`.`name` FROM (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` WHERE `photos`.`user_id` = 1 GROUP BY `photos`.`user_id`) AS `photos_aggregation` INNER JOIN `users` diff --git a/spec/arel/integration/joins/with_compounds_spec.rb b/spec/arel/integration/joins/with_compounds_spec.rb index 62d226acf2..3c17ab315d 100644 --- a/spec/arel/integration/joins/with_compounds_spec.rb +++ b/spec/arel/integration/joins/with_compounds_spec.rb @@ -9,11 +9,11 @@ module Arel end describe '#to_sql' do - describe 'when the join contains a select' do - describe 'and the select is given a string' do + describe 'when the join contains a where' do + describe 'and the where is given a string' do it 'does not escape the string' do @relation1 \ - .join(@relation2.select("asdf")) \ + .join(@relation2.where("asdf")) \ .on(@predicate) \ .to_sql.should be_like(" SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id` @@ -26,13 +26,13 @@ module Arel end describe 'when a compound contains a join' do - describe 'and the compound is a select' do + describe 'and the compound is a where' do it 'manufactures sql disambiguating the tables' do @relation1 \ - .select(@relation1[:id].eq(1)) \ + .where(@relation1[:id].eq(1)) \ .join(@relation2) \ .on(@predicate) \ - .select(@relation1[:id].eq(1)) \ + .where(@relation1[:id].eq(1)) \ .to_sql.should be_like(" SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id` FROM `users` diff --git a/spec/arel/unit/primitives/attribute_spec.rb b/spec/arel/unit/primitives/attribute_spec.rb index 890ac0e813..b341c6f88e 100644 --- a/spec/arel/unit/primitives/attribute_spec.rb +++ b/spec/arel/unit/primitives/attribute_spec.rb @@ -16,7 +16,7 @@ module Arel describe '#bind' do it "manufactures an attribute with the relation bound and self as an ancestor" do - derived_relation = @relation.select(@relation[:id].eq(1)) + derived_relation = @relation.where(@relation[:id].eq(1)) @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, :ancestor => @attribute) end diff --git a/spec/arel/unit/primitives/expression_spec.rb b/spec/arel/unit/primitives/expression_spec.rb index 8a990231f6..d398805fe2 100644 --- a/spec/arel/unit/primitives/expression_spec.rb +++ b/spec/arel/unit/primitives/expression_spec.rb @@ -14,7 +14,7 @@ module Arel describe '#bind' do it "manufactures an attribute with a rebound relation and self as the ancestor" do - derived_relation = @relation.select(@relation[:id].eq(1)) + derived_relation = @relation.where(@relation[:id].eq(1)) @expression.bind(derived_relation).should == Expression.new(@attribute.bind(derived_relation), "COUNT", nil, @expression) end diff --git a/spec/arel/unit/relations/alias_spec.rb b/spec/arel/unit/relations/alias_spec.rb index ce35debadf..5327154fa8 100644 --- a/spec/arel/unit/relations/alias_spec.rb +++ b/spec/arel/unit/relations/alias_spec.rb @@ -17,7 +17,7 @@ module Arel describe 'when there is no ambiguity' do it 'does not alias table names anywhere a table name can appear' do @relation \ - .select(@relation[:id].eq(1)) \ + .where(@relation[:id].eq(1)) \ .order(@relation[:id]) \ .project(@relation[:id]) \ .group(@relation[:id]) \ diff --git a/spec/arel/unit/relations/deletion_spec.rb b/spec/arel/unit/relations/deletion_spec.rb index f975720d83..46c2ec9143 100644 --- a/spec/arel/unit/relations/deletion_spec.rb +++ b/spec/arel/unit/relations/deletion_spec.rb @@ -14,8 +14,8 @@ module Arel ") end - it 'manufactures sql deleting a selection relation' do - Deletion.new(@relation.select(@relation[:id].eq(1))).to_sql.should be_like(" + it 'manufactures sql deleting a where relation' do + Deletion.new(@relation.where(@relation[:id].eq(1))).to_sql.should be_like(" DELETE FROM `users` WHERE `users`.`id` = 1 diff --git a/spec/arel/unit/relations/relation_spec.rb b/spec/arel/unit/relations/relation_spec.rb index d9ae8e0742..78e391640e 100644 --- a/spec/arel/unit/relations/relation_spec.rb +++ b/spec/arel/unit/relations/relation_spec.rb @@ -78,22 +78,22 @@ module Arel end end - describe '#select' do + describe '#where' do before do @predicate = Equality.new(@attribute1, @attribute2) end - it "manufactures a selection relation" do - @relation.select(@predicate).should == Selection.new(@relation, @predicate) + it "manufactures a where relation" do + @relation.where(@predicate).should == Where.new(@relation, @predicate) end it "accepts arbitrary strings" do - @relation.select("arbitrary").should == Selection.new(@relation, "arbitrary") + @relation.where("arbitrary").should == Where.new(@relation, "arbitrary") end describe 'when given a blank predicate' do it 'returns self' do - @relation.select.should == @relation + @relation.where.should == @relation end end end diff --git a/spec/arel/unit/relations/update_spec.rb b/spec/arel/unit/relations/update_spec.rb index f411781392..08c6da7901 100644 --- a/spec/arel/unit/relations/update_spec.rb +++ b/spec/arel/unit/relations/update_spec.rb @@ -48,15 +48,15 @@ module Arel end end - describe 'when the relation is a selection' do + describe 'when the relation is a where' do before do @update = Update.new( - @relation.select(@relation[:id].eq(1)), + @relation.where(@relation[:id].eq(1)), @relation[:name] => "nick" ) end - it 'manufactures sql updating a selection relation' do + it 'manufactures sql updating a where relation' do @update.to_sql.should be_like(" UPDATE `users` SET `users`.`name` = 'nick' diff --git a/spec/arel/unit/relations/selection_spec.rb b/spec/arel/unit/relations/where_spec.rb index 20807f952f..aa14fd7bdc 100644 --- a/spec/arel/unit/relations/selection_spec.rb +++ b/spec/arel/unit/relations/where_spec.rb @@ -1,24 +1,24 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') module Arel - describe Selection do + describe Where do before do @relation = Table.new(:users) @predicate = @relation[:id].eq(1) end describe '#initialize' do - it "manufactures nested selection relations if multiple predicates are provided" do + it "manufactures nested where relations if multiple predicates are provided" do another_predicate = @relation[:name].lt(2) - Selection.new(@relation, @predicate, another_predicate). \ - should == Selection.new(Selection.new(@relation, another_predicate), @predicate) + Where.new(@relation, @predicate, another_predicate). \ + should == Where.new(Where.new(@relation, another_predicate), @predicate) end end describe '#to_sql' do describe 'when given a predicate' do it "manufactures sql with where clause conditions" do - Selection.new(@relation, @predicate).to_sql.should be_like(" + Where.new(@relation, @predicate).to_sql.should be_like(" SELECT `users`.`id`, `users`.`name` FROM `users` WHERE `users`.`id` = 1 @@ -28,7 +28,7 @@ module Arel describe 'when given a string' do it "passes the string through to the where clause" do - Selection.new(@relation, 'asdf').to_sql.should be_like(" + Where.new(@relation, 'asdf').to_sql.should be_like(" SELECT `users`.`id`, `users`.`name` FROM `users` WHERE asdf |