aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-03-10 18:16:07 -0300
committerEmilio Tagua <miloops@gmail.com>2010-03-10 18:16:07 -0300
commitb706f690b611d647aae15a85caa19d167814ae3c (patch)
tree05a17b2e937f894ea03f3fff535fd62cbc31a025 /spec/arel
parentc03d4bb8e4acac95961a1a9eb9578fa33a47da66 (diff)
downloadrails-b706f690b611d647aae15a85caa19d167814ae3c.tar.gz
rails-b706f690b611d647aae15a85caa19d167814ae3c.tar.bz2
rails-b706f690b611d647aae15a85caa19d167814ae3c.zip
Arel doesn't has to know if a table or column exists.
Diffstat (limited to 'spec/arel')
-rw-r--r--spec/arel/algebra/unit/relations/relation_spec.rb3
-rw-r--r--spec/arel/algebra/unit/relations/table_spec.rb1
-rw-r--r--spec/arel/engines/sql/unit/primitives/attribute_spec.rb21
3 files changed, 21 insertions, 4 deletions
diff --git a/spec/arel/algebra/unit/relations/relation_spec.rb b/spec/arel/algebra/unit/relations/relation_spec.rb
index cf6509fe6a..a1d1793d92 100644
--- a/spec/arel/algebra/unit/relations/relation_spec.rb
+++ b/spec/arel/algebra/unit/relations/relation_spec.rb
@@ -16,10 +16,9 @@ module Arel
end
describe 'when given a', Symbol, String do
- it "returns the attribute with the same name, if it exists" do
+ it "returns the attribute with the same name" do
check @relation[:id].should == @attribute1
check @relation['id'].should == @attribute1
- @relation[:does_not_exist].should be_nil
end
end
end
diff --git a/spec/arel/algebra/unit/relations/table_spec.rb b/spec/arel/algebra/unit/relations/table_spec.rb
index 19c1ba2bea..d93446f1b9 100644
--- a/spec/arel/algebra/unit/relations/table_spec.rb
+++ b/spec/arel/algebra/unit/relations/table_spec.rb
@@ -10,7 +10,6 @@ module Arel
describe 'when given a', Symbol do
it "manufactures an attribute if the symbol names an attribute within the relation" do
check @relation[:id].should == Attribute.new(@relation, :id)
- @relation[:does_not_exist].should be_nil
end
end
diff --git a/spec/arel/engines/sql/unit/primitives/attribute_spec.rb b/spec/arel/engines/sql/unit/primitives/attribute_spec.rb
index 9f864dd3a1..8daa0d9fd5 100644
--- a/spec/arel/engines/sql/unit/primitives/attribute_spec.rb
+++ b/spec/arel/engines/sql/unit/primitives/attribute_spec.rb
@@ -9,7 +9,7 @@ module Arel
describe '#column' do
it "returns the corresponding column in the relation" do
- @attribute.column.should == @relation.column_for(@attribute)
+ @attribute.column.should == @relation.column_for(@attribute)
end
end
@@ -31,6 +31,25 @@ module Arel
end
end
end
+
+ describe 'for an inexistent attribute' do
+ it "manufactures sql" do
+ sql = @relation[:does_not_exist].to_sql
+
+ adapter_is :mysql do
+ sql.should be_like(%Q{`users`.`does_not_exist`})
+ end
+
+ adapter_is :oracle do
+ sql.should be_like(%Q{"USERS"."DOEST_NOT_EXIST"})
+ end
+
+ adapter_is_not :mysql, :oracle do
+ sql.should be_like(%Q{"users"."does_not_exist"})
+ end
+ end
+ end
+
end
end
end