From 3eae3b08eef84237c201a2f7bfc5292dbbe6951c Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Mon, 19 May 2008 13:49:43 -0700 Subject: renamed select operation to where --- spec/arel/unit/primitives/attribute_spec.rb | 2 +- spec/arel/unit/primitives/expression_spec.rb | 2 +- spec/arel/unit/relations/alias_spec.rb | 2 +- spec/arel/unit/relations/deletion_spec.rb | 4 +-- spec/arel/unit/relations/relation_spec.rb | 10 +++---- spec/arel/unit/relations/selection_spec.rb | 40 ---------------------------- spec/arel/unit/relations/update_spec.rb | 6 ++--- spec/arel/unit/relations/where_spec.rb | 40 ++++++++++++++++++++++++++++ 8 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 spec/arel/unit/relations/selection_spec.rb create mode 100644 spec/arel/unit/relations/where_spec.rb (limited to 'spec/arel/unit') 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/selection_spec.rb b/spec/arel/unit/relations/selection_spec.rb deleted file mode 100644 index 20807f952f..0000000000 --- a/spec/arel/unit/relations/selection_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') - -module Arel - describe Selection 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 - another_predicate = @relation[:name].lt(2) - Selection.new(@relation, @predicate, another_predicate). \ - should == Selection.new(Selection.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(" - SELECT `users`.`id`, `users`.`name` - FROM `users` - WHERE `users`.`id` = 1 - ") - end - end - - 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(" - SELECT `users`.`id`, `users`.`name` - FROM `users` - WHERE asdf - ") - end - end - end - end -end \ No newline at end of file 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/where_spec.rb b/spec/arel/unit/relations/where_spec.rb new file mode 100644 index 0000000000..aa14fd7bdc --- /dev/null +++ b/spec/arel/unit/relations/where_spec.rb @@ -0,0 +1,40 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper') + +module Arel + describe Where do + before do + @relation = Table.new(:users) + @predicate = @relation[:id].eq(1) + end + + describe '#initialize' do + it "manufactures nested where relations if multiple predicates are provided" do + another_predicate = @relation[:name].lt(2) + 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 + Where.new(@relation, @predicate).to_sql.should be_like(" + SELECT `users`.`id`, `users`.`name` + FROM `users` + WHERE `users`.`id` = 1 + ") + end + end + + describe 'when given a string' do + it "passes the string through to the where clause" do + Where.new(@relation, 'asdf').to_sql.should be_like(" + SELECT `users`.`id`, `users`.`name` + FROM `users` + WHERE asdf + ") + end + end + end + end +end \ No newline at end of file -- cgit v1.2.3