aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-05-06 14:14:56 -0300
committerEmilio Tagua <miloops@gmail.com>2009-05-06 14:14:56 -0300
commita7dea38204f3c40e4d0c3f29ebe17af818659697 (patch)
tree3a3a912b74b15509c715ec5028b18da49bd30d44 /spec/arel
parentde843c86518e4ac871d4bb5b0873bb6c184ac304 (diff)
downloadrails-a7dea38204f3c40e4d0c3f29ebe17af818659697.tar.gz
rails-a7dea38204f3c40e4d0c3f29ebe17af818659697.tar.bz2
rails-a7dea38204f3c40e4d0c3f29ebe17af818659697.zip
Don't depend engine select_value(s) method. Quoting should be performed by connection not ARel
Diffstat (limited to 'spec/arel')
-rw-r--r--spec/arel/integration/joins/with_adjacency_spec.rb20
-rw-r--r--spec/arel/integration/joins/with_aggregations_spec.rb12
-rw-r--r--spec/arel/integration/joins/with_compounds_spec.rb8
-rw-r--r--spec/arel/unit/primitives/value_spec.rb4
-rw-r--r--spec/arel/unit/relations/delete_spec.rb10
-rw-r--r--spec/arel/unit/relations/project_spec.rb4
-rw-r--r--spec/arel/unit/relations/where_spec.rb10
7 files changed, 34 insertions, 34 deletions
diff --git a/spec/arel/integration/joins/with_adjacency_spec.rb b/spec/arel/integration/joins/with_adjacency_spec.rb
index 32109cc354..559b5bbe1a 100644
--- a/spec/arel/integration/joins/with_adjacency_spec.rb
+++ b/spec/arel/integration/joins/with_adjacency_spec.rb
@@ -7,7 +7,7 @@ module Arel
@relation2 = @relation1.alias
@predicate = @relation1[:id].eq(@relation2[:id])
end
-
+
describe 'when joining a relation to itself' do
describe '#to_sql' do
it 'manufactures sql aliasing the table and attributes properly in the join predicate and the where clause' do
@@ -18,7 +18,7 @@ module Arel
ON `users`.`id` = `users_2`.`id`
")
end
-
+
describe 'when joining with a where on the same relation' do
it 'manufactures sql aliasing the tables properly' do
@relation1 \
@@ -31,7 +31,7 @@ module Arel
ON `users`.`id` = `users_2`.`id` AND `users_2`.`id` = 1
")
end
-
+
describe 'when the where occurs before the alias' do
it 'manufactures sql aliasing the predicates properly' do
relation2 = @relation1.where(@relation1[:id].eq(1)).alias
@@ -47,12 +47,12 @@ module Arel
end
end
end
-
+
describe 'when joining the relation to itself multiple times' do
before do
@relation3 = @relation1.alias
end
-
+
describe 'when joining left-associatively' do
it 'manufactures sql aliasing the tables properly' do
@relation1 \
@@ -70,7 +70,7 @@ module Arel
")
end
end
-
+
describe 'when joining right-associatively' do
it 'manufactures sql aliasing the tables properly' do
@relation1 \
@@ -88,7 +88,7 @@ module Arel
end
end
end
-
+
describe '[]' do
describe 'when given an attribute belonging to both sub-relations' do
it 'disambiguates the relation that serves as the ancestor to the attribute' do
@@ -108,7 +108,7 @@ module Arel
.should disambiguate_attributes(compound1[:id], compound2[:id])
end
end
-
+
describe 'when the left relation is extremely compound' do
it 'disambiguates the relation that serves as the ancestor to the attribute' do
@relation1 \
@@ -119,7 +119,7 @@ module Arel
.should disambiguate_attributes(@relation1[:id], @relation2[:id])
end
end
-
+
describe 'when the right relation is extremely compound' do
it 'disambiguates the relation that serves as the ancestor to the attribute' do
@relation1 \
@@ -136,4 +136,4 @@ module Arel
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/arel/integration/joins/with_aggregations_spec.rb b/spec/arel/integration/joins/with_aggregations_spec.rb
index 42248add07..2b21dcaa1e 100644
--- a/spec/arel/integration/joins/with_aggregations_spec.rb
+++ b/spec/arel/integration/joins/with_aggregations_spec.rb
@@ -7,14 +7,14 @@ module Arel
@relation2 = Arel(:photos)
@predicate = @relation1[:id].eq(@relation2[:user_id])
end
-
+
describe 'when joining aggregated relations' do
before do
@aggregation = @relation2 \
.group(@relation2[:user_id]) \
.project(@relation2[:user_id], @relation2[:id].count.as(:cnt)) \
end
-
+
describe '#to_sql' do
# CLEANUP
it '' do
@@ -25,7 +25,7 @@ module Arel
ON `users`.`id` = `photos_external`.`user_id`
")
end
-
+
describe 'with the aggregation on the right' do
it 'manufactures sql joining the left table to a derived table' do
@relation1.join(@aggregation).on(@predicate).to_sql.should be_like("
@@ -47,7 +47,7 @@ module Arel
")
end
end
-
+
describe 'with the aggregation on both sides' do
it 'it properly aliases the aggregations' do
aggregation2 = @aggregation.alias
@@ -71,7 +71,7 @@ module Arel
")
end
end
-
+
describe 'with the aggregation on the right' do
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("
@@ -86,4 +86,4 @@ module Arel
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/arel/integration/joins/with_compounds_spec.rb b/spec/arel/integration/joins/with_compounds_spec.rb
index acfe35b25e..95fadc23d6 100644
--- a/spec/arel/integration/joins/with_compounds_spec.rb
+++ b/spec/arel/integration/joins/with_compounds_spec.rb
@@ -7,7 +7,7 @@ module Arel
@relation2 = Arel(:photos)
@predicate = @relation1[:id].eq(@relation2[:user_id])
end
-
+
describe '#to_sql' do
describe 'when the join contains a where' do
describe 'and the where is given a string' do
@@ -24,7 +24,7 @@ module Arel
end
end
end
-
+
describe 'when a compound contains a join' do
describe 'and the compound is a where' do
it 'manufactures sql disambiguating the tables' do
@@ -43,7 +43,7 @@ module Arel
")
end
end
-
+
describe 'and the compound is a group' do
it 'manufactures sql disambiguating the tables' do
@relation1 \
@@ -62,4 +62,4 @@ module Arel
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/arel/unit/primitives/value_spec.rb b/spec/arel/unit/primitives/value_spec.rb
index 87425c780d..ba9a80bb49 100644
--- a/spec/arel/unit/primitives/value_spec.rb
+++ b/spec/arel/unit/primitives/value_spec.rb
@@ -5,7 +5,7 @@ module Arel
before do
@relation = Table.new(:users)
end
-
+
describe '#to_sql' do
it "appropriately quotes the value" do
Value.new(1, @relation).to_sql.should be_like('1')
@@ -25,4 +25,4 @@ module Arel
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/arel/unit/relations/delete_spec.rb b/spec/arel/unit/relations/delete_spec.rb
index 46c2ec9143..fa887d20fd 100644
--- a/spec/arel/unit/relations/delete_spec.rb
+++ b/spec/arel/unit/relations/delete_spec.rb
@@ -5,7 +5,7 @@ module Arel
before do
@relation = Table.new(:users)
end
-
+
describe '#to_sql' do
it 'manufactures sql deleting a table relation' do
Deletion.new(@relation).to_sql.should be_like("
@@ -13,7 +13,7 @@ module Arel
FROM `users`
")
end
-
+
it 'manufactures sql deleting a where relation' do
Deletion.new(@relation.where(@relation[:id].eq(1))).to_sql.should be_like("
DELETE
@@ -21,7 +21,7 @@ module Arel
WHERE `users`.`id` = 1
")
end
-
+
it "manufactures sql deleting a ranged relation" do
Deletion.new(@relation.take(1)).to_sql.should be_like("
DELETE
@@ -30,7 +30,7 @@ module Arel
")
end
end
-
+
describe '#call' do
it 'executes a delete on the connection' do
deletion = Deletion.new(@relation)
@@ -39,4 +39,4 @@ module Arel
end
end
end
-end \ No newline at end of file
+end
diff --git a/spec/arel/unit/relations/project_spec.rb b/spec/arel/unit/relations/project_spec.rb
index 7f531096f0..f389b18c54 100644
--- a/spec/arel/unit/relations/project_spec.rb
+++ b/spec/arel/unit/relations/project_spec.rb
@@ -50,14 +50,14 @@ module Arel
describe 'when given an expression' do
it 'manufactures sql with expressions' do
@relation.project(@attribute.count).to_sql.should be_like("
- SELECT COUNT(`users`.`id`)
+ SELECT COUNT(`users`.`id`) AS count_id
FROM `users`
")
end
it 'manufactures sql with distinct expressions' do
@relation.project(@attribute.count(true)).to_sql.should be_like("
- SELECT COUNT(DISTINCT `users`.`id`)
+ SELECT COUNT(DISTINCT `users`.`id`) AS count_id
FROM `users`
")
end
diff --git a/spec/arel/unit/relations/where_spec.rb b/spec/arel/unit/relations/where_spec.rb
index aa14fd7bdc..8ef4d54b63 100644
--- a/spec/arel/unit/relations/where_spec.rb
+++ b/spec/arel/unit/relations/where_spec.rb
@@ -6,15 +6,15 @@ module Arel
@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)
+ 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
@@ -25,7 +25,7 @@ module Arel
")
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("
@@ -37,4 +37,4 @@ module Arel
end
end
end
-end \ No newline at end of file
+end