aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel/unit/relations/join_spec.rb
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-04 16:50:03 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-04 16:50:03 -0700
commitf413129f37bbbc4100317cb60179f43291e69f8e (patch)
treef640bfb9223d60f7ed46add9f157f30048b245bb /spec/arel/unit/relations/join_spec.rb
parent85bc3b417dc4e1ecad76fa89b5d195e2db8f5ff5 (diff)
downloadrails-f413129f37bbbc4100317cb60179f43291e69f8e.tar.gz
rails-f413129f37bbbc4100317cb60179f43291e69f8e.tar.bz2
rails-f413129f37bbbc4100317cb60179f43291e69f8e.zip
Table names seem to be disambiguated.
- Code is a mess, about to undergo some refactoring
Diffstat (limited to 'spec/arel/unit/relations/join_spec.rb')
-rw-r--r--spec/arel/unit/relations/join_spec.rb22
1 files changed, 3 insertions, 19 deletions
diff --git a/spec/arel/unit/relations/join_spec.rb b/spec/arel/unit/relations/join_spec.rb
index 0c2d1d771d..52e1a93b8e 100644
--- a/spec/arel/unit/relations/join_spec.rb
+++ b/spec/arel/unit/relations/join_spec.rb
@@ -47,15 +47,6 @@ module Arel
end
end
- describe '#prefix_for' do
- it "returns the name of the relation containing the attribute" do
- Join.new("INNER JOIN", @relation1, @relation2, @predicate).prefix_for(@relation1[:id]) \
- .should == @relation1.prefix_for(@relation1[:id])
- Join.new("INNER JOIN", @relation1, @relation2, @predicate).prefix_for(@relation2[:id]) \
- .should == @relation2.prefix_for(@relation2[:id])
- end
- end
-
describe '#to_sql' do
it 'manufactures sql joining the two tables on the predicate' do
Join.new("INNER JOIN", @relation1, @relation2, @predicate).to_sql.should be_like("
@@ -116,6 +107,7 @@ module Arel
end
end
+ # TESTME try other direction too!
it "keeps selects on the aggregation within the derived table" do
Join.new("INNER JOIN", @relation1, @aggregation.select(@aggregation[:user_id].eq(1)), @predicate).to_sql.should be_like("
SELECT `users`.`id`, `users`.`name`, `photos_aggregation`.`user_id`, `photos_aggregation`.`cnt`
@@ -133,16 +125,6 @@ module Arel
@predicate = @relation1[:id].eq(@aliased_relation[:id])
end
- describe '#prefix_for' do
- it "returns the alias of the relation containing the attribute" do
- relation = Join.new("INNER JOIN", @relation1, @aliased_relation, @predicate)
- relation.prefix_for(@aliased_relation[:id]) \
- .should == @relation1.name
- relation.prefix_for(@relation1[:id]) \
- .should == @relation1.name + '_2'
- end
- end
-
describe 'when joining the same relation to itself' do
describe '#to_sql' do
it '' do
@@ -151,6 +133,7 @@ module Arel
@relation1 \
.join(relation2.join(relation3).on(relation2[:id].eq(relation3[:id]))) \
.on(@relation1[:id].eq(relation2[:id])) \
+ .select(@relation1[:id].eq(1)) \
.to_sql.should be_like("
SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`, `users_3`.`id`, `users_3`.`name`
FROM `users`
@@ -158,6 +141,7 @@ module Arel
ON `users`.`id` = `users_2`.`id`
INNER JOIN `users` AS `users_3`
ON `users_2`.`id` = `users_3`.`id`
+ WHERE `users`.`id` = 1
")
end