aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-24 15:21:54 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-24 15:21:54 -0700
commit6b86ae4f9f2fb8cd145f958753fedf16aae3a0d4 (patch)
treefff66461830df50e3211d8ced131584e6d75f9d4
parent245d797a8ccab3ed2de9a0eedf455d3094a091ce (diff)
downloadrails-6b86ae4f9f2fb8cd145f958753fedf16aae3a0d4.tar.gz
rails-6b86ae4f9f2fb8cd145f958753fedf16aae3a0d4.tar.bz2
rails-6b86ae4f9f2fb8cd145f958753fedf16aae3a0d4.zip
shuffling around the spec directory
-rw-r--r--spec/activerecord_compat_spec.rb (renamed from spec/arel/activerecord_compat_spec.rb)0
-rw-r--r--spec/algebra/unit/predicates/binary_spec.rb35
-rw-r--r--spec/algebra/unit/predicates/equality_spec.rb29
-rw-r--r--spec/algebra/unit/predicates/in_spec.rb12
-rw-r--r--spec/algebra/unit/predicates/inequality_spec.rb32
-rw-r--r--spec/algebra/unit/predicates/predicate_spec.rb22
-rw-r--r--spec/algebra/unit/primitives/attribute_spec.rb175
-rw-r--r--spec/algebra/unit/primitives/expression_spec.rb39
-rw-r--r--spec/algebra/unit/primitives/value_spec.rb15
-rw-r--r--spec/algebra/unit/relations/alias_spec.rb16
-rw-r--r--spec/algebra/unit/relations/delete_spec.rb9
-rw-r--r--spec/algebra/unit/relations/group_spec.rb10
-rw-r--r--spec/algebra/unit/relations/insert_spec.rb9
-rw-r--r--spec/algebra/unit/relations/join_spec.rb18
-rw-r--r--spec/algebra/unit/relations/order_spec.rb21
-rw-r--r--spec/algebra/unit/relations/project_spec.rb34
-rw-r--r--spec/algebra/unit/relations/relation_spec.rb236
-rw-r--r--spec/algebra/unit/relations/skip_spec.rb10
-rw-r--r--spec/algebra/unit/relations/take_spec.rb10
-rw-r--r--spec/algebra/unit/relations/update_spec.rb9
-rw-r--r--spec/algebra/unit/relations/where_spec.rb19
-rw-r--r--spec/algebra/unit/session/session_spec.rb84
-rw-r--r--spec/attributes/attribute_spec.rb (renamed from spec/arel/attributes/attribute_spec.rb)0
-rw-r--r--spec/attributes/boolean_spec.rb57
-rw-r--r--spec/attributes/float_spec.rb119
-rw-r--r--spec/attributes/header_spec.rb42
-rw-r--r--spec/attributes/integer_spec.rb119
-rw-r--r--spec/attributes/string_spec.rb43
-rw-r--r--spec/attributes/time_spec.rb24
-rw-r--r--spec/attributes_spec.rb (renamed from spec/arel/attributes_spec.rb)0
-rw-r--r--spec/crud_spec.rb (renamed from spec/arel/crud_spec.rb)0
-rw-r--r--spec/delete_manager_spec.rb (renamed from spec/arel/delete_manager_spec.rb)0
-rw-r--r--spec/engines/memory/integration/joins/cross_engine_spec.rb61
-rw-r--r--spec/engines/memory/unit/relations/array_spec.rb33
-rw-r--r--spec/engines/memory/unit/relations/insert_spec.rb28
-rw-r--r--spec/engines/memory/unit/relations/join_spec.rb32
-rw-r--r--spec/engines/memory/unit/relations/order_spec.rb28
-rw-r--r--spec/engines/memory/unit/relations/project_spec.rb27
-rw-r--r--spec/engines/memory/unit/relations/skip_spec.rb31
-rw-r--r--spec/engines/memory/unit/relations/take_spec.rb28
-rw-r--r--spec/engines/memory/unit/relations/where_spec.rb43
-rw-r--r--spec/engines/sql/integration/joins/with_adjacency_spec.rb258
-rw-r--r--spec/engines/sql/integration/joins/with_aggregations_spec.rb221
-rw-r--r--spec/engines/sql/integration/joins/with_compounds_spec.rb137
-rw-r--r--spec/engines/sql/unit/engine_spec.rb65
-rw-r--r--spec/engines/sql/unit/predicates/binary_spec.rb140
-rw-r--r--spec/engines/sql/unit/predicates/equality_spec.rb75
-rw-r--r--spec/engines/sql/unit/predicates/in_spec.rb179
-rw-r--r--spec/engines/sql/unit/predicates/noteq_spec.rb75
-rw-r--r--spec/engines/sql/unit/predicates/predicates_spec.rb79
-rw-r--r--spec/engines/sql/unit/primitives/attribute_spec.rb36
-rw-r--r--spec/engines/sql/unit/primitives/expression_spec.rb28
-rw-r--r--spec/engines/sql/unit/primitives/literal_spec.rb43
-rw-r--r--spec/engines/sql/unit/primitives/value_spec.rb29
-rw-r--r--spec/engines/sql/unit/relations/alias_spec.rb53
-rw-r--r--spec/engines/sql/unit/relations/delete_spec.rb83
-rw-r--r--spec/engines/sql/unit/relations/from_spec.rb64
-rw-r--r--spec/engines/sql/unit/relations/group_spec.rb72
-rw-r--r--spec/engines/sql/unit/relations/having_spec.rb78
-rw-r--r--spec/engines/sql/unit/relations/insert_spec.rb143
-rw-r--r--spec/engines/sql/unit/relations/join_spec.rb180
-rw-r--r--spec/engines/sql/unit/relations/lock_spec.rb86
-rw-r--r--spec/engines/sql/unit/relations/order_spec.rb161
-rw-r--r--spec/engines/sql/unit/relations/project_spec.rb143
-rw-r--r--spec/engines/sql/unit/relations/skip_spec.rb41
-rw-r--r--spec/engines/sql/unit/relations/table_spec.rb122
-rw-r--r--spec/engines/sql/unit/relations/take_spec.rb75
-rw-r--r--spec/engines/sql/unit/relations/update_spec.rb203
-rw-r--r--spec/engines/sql/unit/relations/where_spec.rb72
-rw-r--r--spec/insert_manager_spec.rb (renamed from spec/arel/insert_manager_spec.rb)0
-rw-r--r--spec/nodes/count_spec.rb (renamed from spec/arel/nodes/count_spec.rb)0
-rw-r--r--spec/nodes/delete_statement_spec.rb (renamed from spec/arel/nodes/delete_statement_spec.rb)0
-rw-r--r--spec/nodes/equality_spec.rb (renamed from spec/arel/nodes/equality_spec.rb)0
-rw-r--r--spec/nodes/insert_statement_spec.rb (renamed from spec/arel/nodes/insert_statement_spec.rb)0
-rw-r--r--spec/nodes/or_spec.rb (renamed from spec/arel/nodes/or_spec.rb)0
-rw-r--r--spec/nodes/select_core_spec.rb (renamed from spec/arel/nodes/select_core_spec.rb)0
-rw-r--r--spec/nodes/select_statement_spec.rb (renamed from spec/arel/nodes/select_statement_spec.rb)0
-rw-r--r--spec/nodes/sql_literal_spec.rb (renamed from spec/arel/nodes/sql_literal_spec.rb)0
-rw-r--r--spec/nodes/sum_spec.rb (renamed from spec/arel/nodes/sum_spec.rb)0
-rw-r--r--spec/nodes/update_statement_spec.rb (renamed from spec/arel/nodes/update_statement_spec.rb)0
-rw-r--r--spec/relations/join_spec.rb42
-rw-r--r--spec/relations/relation_spec.rb31
-rw-r--r--spec/select_manager_spec.rb (renamed from spec/arel/select_manager_spec.rb)0
-rw-r--r--spec/shared/relation_spec.rb255
-rw-r--r--spec/sql/christener_spec.rb70
-rw-r--r--spec/table_spec.rb (renamed from spec/arel/table_spec.rb)0
-rw-r--r--spec/update_manager_spec.rb (renamed from spec/arel/update_manager_spec.rb)0
-rw-r--r--spec/visitors/join_sql_spec.rb (renamed from spec/arel/visitors/join_sql_spec.rb)0
-rw-r--r--spec/visitors/oracle_spec.rb (renamed from spec/arel/visitors/oracle_spec.rb)0
-rw-r--r--spec/visitors/to_sql_spec.rb (renamed from spec/arel/visitors/to_sql_spec.rb)0
90 files changed, 0 insertions, 4898 deletions
diff --git a/spec/arel/activerecord_compat_spec.rb b/spec/activerecord_compat_spec.rb
index a7eeb7e5ee..a7eeb7e5ee 100644
--- a/spec/arel/activerecord_compat_spec.rb
+++ b/spec/activerecord_compat_spec.rb
diff --git a/spec/algebra/unit/predicates/binary_spec.rb b/spec/algebra/unit/predicates/binary_spec.rb
deleted file mode 100644
index 051aeeeb6e..0000000000
--- a/spec/algebra/unit/predicates/binary_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Binary do
- before do
- @relation = Arel::Table.new(:users)
- @attribute1 = @relation[:id]
- @attribute2 = @relation[:name]
- class ConcreteBinary < Binary
- end
- end
-
- describe '#bind' do
- before do
- @another_relation = @relation.alias
- end
-
- describe 'when both operands are attributes' do
- it "manufactures an expression with the attributes bound to the relation" do
- ConcreteBinary.new(@attribute1, @attribute2).bind(@another_relation). \
- should == ConcreteBinary.new(@another_relation[@attribute1], @another_relation[@attribute2])
- end
- end
-
- describe 'when an operand is a value' do
- it "manufactures an expression with unmodified values" do
- ConcreteBinary.new(@attribute1, "asdf").bind(@another_relation). \
- should == ConcreteBinary.new(@attribute1.find_correlate_in(@another_relation), "asdf".find_correlate_in(@another_relation))
- end
- end
- end
- end
- end
-end
diff --git a/spec/algebra/unit/predicates/equality_spec.rb b/spec/algebra/unit/predicates/equality_spec.rb
deleted file mode 100644
index 7d1d79ff35..0000000000
--- a/spec/algebra/unit/predicates/equality_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Equality do
- before do
- @relation1 = Arel::Table.new(:users)
- @relation2 = Arel::Table.new(:photos)
- @attribute1 = @relation1[:id]
- @attribute2 = @relation2[:user_id]
- end
-
- describe '==' do
- it "obtains if attribute1 and attribute2 are identical" do
- check Equality.new(@attribute1, @attribute2).should == Equality.new(@attribute1, @attribute2)
- Equality.new(@attribute1, @attribute2).should_not == Equality.new(@attribute1, @attribute1)
- end
-
- it "obtains if the concrete type of the predicates are identical" do
- Equality.new(@attribute1, @attribute2).should_not == Binary.new(@attribute1, @attribute2)
- end
-
- it "is commutative on the attributes" do
- Equality.new(@attribute1, @attribute2).should == Equality.new(@attribute2, @attribute1)
- end
- end
- end
- end
-end
diff --git a/spec/algebra/unit/predicates/in_spec.rb b/spec/algebra/unit/predicates/in_spec.rb
deleted file mode 100644
index b9e15d63a4..0000000000
--- a/spec/algebra/unit/predicates/in_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe In do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
- end
- end
-end
diff --git a/spec/algebra/unit/predicates/inequality_spec.rb b/spec/algebra/unit/predicates/inequality_spec.rb
deleted file mode 100644
index f95b8d120e..0000000000
--- a/spec/algebra/unit/predicates/inequality_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Inequality do
- before do
- relation1 = Arel::Table.new(:users)
- relation2 = Arel::Table.new(:photos)
- left = relation1[:id]
- right = relation2[:user_id]
- @a = Inequality.new(left, right)
- @b = Inequality.new(right, left)
- end
-
- describe 'operator' do
- it "should have one" do
- @a.operator.should == :"!="
- end
- end
-
- describe '==' do
- it "is equal to itself" do
- @a.should == @a
- end
-
- it "should not care abount children order" do
- @a.should == @b
- end
- end
- end
- end
-end
diff --git a/spec/algebra/unit/predicates/predicate_spec.rb b/spec/algebra/unit/predicates/predicate_spec.rb
deleted file mode 100644
index 6acc047cbb..0000000000
--- a/spec/algebra/unit/predicates/predicate_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Polyadic do
- before do
- @relation1 = Arel::Table.new(:users)
- @relation2 = Arel::Table.new(:photos)
- @a = @relation1[:id]
- @b = @relation2[:user_id]
- end
-
- describe '==' do
- left = Polyadic.new @a, @b
- right = Polyadic.new @b, @a
-
- left.should != right
- left.should == right
- end
- end
- end
-end
diff --git a/spec/algebra/unit/primitives/attribute_spec.rb b/spec/algebra/unit/primitives/attribute_spec.rb
deleted file mode 100644
index 4026c0de14..0000000000
--- a/spec/algebra/unit/primitives/attribute_spec.rb
+++ /dev/null
@@ -1,175 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Attribute do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe 'Attribute::Transformations' do
- describe '#as' do
- it "manufactures an aliased attributed" do
- @attribute.as(:alias).should == Attribute.new(@relation, @attribute.name, :alias => :alias, :ancestor => @attribute)
- end
- end
-
- describe '#bind' do
- it "manufactures an attribute with the relation bound and self as an ancestor" do
- derived_relation = @relation.where(@relation[:id].eq(1))
- @attribute.bind(derived_relation).should == Attribute.new(derived_relation, @attribute.name, :ancestor => @attribute)
- end
-
- it "returns self if the substituting to the same relation" do
- @attribute.bind(@relation).should == @attribute
- end
- end
-
- describe '#to_attribute' do
- describe 'when the given relation is the same as the attributes relation' do
- it "returns self" do
- @attribute.to_attribute(@relation).should == @attribute
- end
- end
-
- describe 'when the given relation differs from the attributes relation' do
- it 'binds to the new relation' do
- @attribute.to_attribute(new_relation = @relation.alias).should == @attribute.bind(new_relation)
- end
- end
- end
- end
-
- describe '#column' do
- it "returns the corresponding column in the relation" do
- @attribute.column.should == @relation.column_for(@attribute)
- end
- end
-
- describe '#engine' do
- it "delegates to its relation" do
- Attribute.new(@relation, :id).engine.should == @relation.engine
- end
- end
-
- describe 'Attribute::Congruence' do
- describe '/' do
- before do
- @aliased_relation = @relation.alias
- @doubly_aliased_relation = @aliased_relation.alias
- end
-
- describe 'when dividing two unrelated attributes' do
- it "returns 0.0" do
- (@relation[:id] / @relation[:name]).should == 0.0
- end
- end
-
- describe 'when dividing two matching attributes' do
- it 'returns a the highest score for the most similar attributes' do
- check((@aliased_relation[:id] / @relation[:id]).should == (@aliased_relation[:id] / @relation[:id]))
- (@aliased_relation[:id] / @relation[:id]).should < (@aliased_relation[:id] / @aliased_relation[:id])
- end
- end
- end
- end
-
- describe 'Attribute::Predications' do
- before do
- @attribute = Attribute.new(@relation, :name)
- end
-
- describe '#eq' do
- it "manufactures an equality predicate" do
- @attribute.eq('name').should == Predicates::Equality.new(@attribute, 'name')
- end
- end
-
- describe '#lt' do
- it "manufactures a less-than predicate" do
- @attribute.lt(10).should == Predicates::LessThan.new(@attribute, 10)
- end
- end
-
- describe '#lteq' do
- it "manufactures a less-than or equal-to predicate" do
- @attribute.lteq(10).should == Predicates::LessThanOrEqualTo.new(@attribute, 10)
- end
- end
-
- describe '#gt' do
- it "manufactures a greater-than predicate" do
- @attribute.gt(10).should == Predicates::GreaterThan.new(@attribute, 10)
- end
- end
-
- describe '#gteq' do
- it "manufactures a greater-than or equal-to predicate" do
- @attribute.gteq(10).should == Predicates::GreaterThanOrEqualTo.new(@attribute, 10)
- end
- end
-
- describe '#matches' do
- it "manufactures a match predicate" do
- @attribute.matches(/.*/).should == Predicates::Match.new(@attribute, /.*/)
- end
- end
-
- describe '#in' do
- it "manufactures an in predicate" do
- @attribute.in(1..30).should == Predicates::In.new(@attribute, (1..30))
- end
- end
- end
-
- describe Attribute::Expressions do
- before do
- @attribute = Attribute.new(@relation, :name)
- end
-
- describe '#count' do
- it "manufactures a count Expression" do
- @attribute.count.should == Count.new(@attribute)
- end
- end
-
- describe '#sum' do
- it "manufactures a sum Expression" do
- @attribute.sum.should == Sum.new(@attribute)
- end
- end
-
- describe '#maximum' do
- it "manufactures a maximum Expression" do
- @attribute.maximum.should == Maximum.new(@attribute)
- end
- end
-
- describe '#minimum' do
- it "manufactures a minimum Expression" do
- @attribute.minimum.should == Minimum.new(@attribute)
- end
- end
-
- describe '#average' do
- it "manufactures an average Expression" do
- @attribute.average.should == Average.new(@attribute)
- end
- end
- end
-
- describe Attribute::Orderings do
- describe '#asc' do
- it 'manufactures an ascending ordering' do
- @attribute.asc.should == Ascending.new(@attribute)
- end
- end
-
- describe '#desc' do
- it 'manufactures a descending ordering' do
- @attribute.desc.should == Descending.new(@attribute)
- end
- end
- end
- end
-end
diff --git a/spec/algebra/unit/primitives/expression_spec.rb b/spec/algebra/unit/primitives/expression_spec.rb
deleted file mode 100644
index f95ef69f96..0000000000
--- a/spec/algebra/unit/primitives/expression_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Expression do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe 'Expression::Transformations' do
- before do
- @expression = Count.new(@attribute)
- end
-
- describe '#bind' do
- it "manufactures an attribute with a rebound relation and self as the ancestor" do
- derived_relation = @relation.where(@relation[:id].eq(1))
- @expression.bind(derived_relation).should == Count.new(@attribute.bind(derived_relation), nil, @expression)
- end
-
- it "returns self if the substituting to the same relation" do
- @expression.bind(@relation).should == @expression
- end
- end
-
- describe '#as' do
- it "manufactures an aliased expression" do
- @expression.as(:alias).should == Expression.new(@attribute, :alias, @expression)
- end
- end
-
- describe '#to_attribute' do
- it "manufactures an attribute with the expression as an ancestor" do
- @expression.to_attribute(@relation).should == Attribute.new(@relation, @expression.alias, :ancestor => @expression)
- end
- end
- end
- end
-end
diff --git a/spec/algebra/unit/primitives/value_spec.rb b/spec/algebra/unit/primitives/value_spec.rb
deleted file mode 100644
index 8fed752d66..0000000000
--- a/spec/algebra/unit/primitives/value_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Value do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#bind' do
- it "manufactures a new value whose relation is the provided relation" do
- Value.new(1, @relation).bind(another_relation = Table.new(:photos)).should == Value.new(1, another_relation)
- end
- end
- end
-end
diff --git a/spec/algebra/unit/relations/alias_spec.rb b/spec/algebra/unit/relations/alias_spec.rb
deleted file mode 100644
index eaf31652b9..0000000000
--- a/spec/algebra/unit/relations/alias_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Alias do
- before do
- @relation = Table.new(:users)
- end
-
- describe '==' do
- it "obtains if the objects are the same" do
- check Alias.new(@relation).should_not == Alias.new(@relation)
- (aliaz = Alias.new(@relation)).should == aliaz
- end
- end
- end
-end
diff --git a/spec/algebra/unit/relations/delete_spec.rb b/spec/algebra/unit/relations/delete_spec.rb
deleted file mode 100644
index c244be8631..0000000000
--- a/spec/algebra/unit/relations/delete_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Deletion do
- before do
- @relation = Table.new(:users)
- end
- end
-end
diff --git a/spec/algebra/unit/relations/group_spec.rb b/spec/algebra/unit/relations/group_spec.rb
deleted file mode 100644
index 48fc818682..0000000000
--- a/spec/algebra/unit/relations/group_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Group do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
- end
-end
diff --git a/spec/algebra/unit/relations/insert_spec.rb b/spec/algebra/unit/relations/insert_spec.rb
deleted file mode 100644
index 3141fa2fc4..0000000000
--- a/spec/algebra/unit/relations/insert_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Insert do
- before do
- @relation = Table.new(:users)
- end
- end
-end
diff --git a/spec/algebra/unit/relations/join_spec.rb b/spec/algebra/unit/relations/join_spec.rb
deleted file mode 100644
index 54034a2e32..0000000000
--- a/spec/algebra/unit/relations/join_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @relation1 = Table.new(:users)
- @relation2 = Table.new(:photos)
- @predicate = @relation1[:id].eq(@relation2[:user_id])
- end
-
- describe '#attributes' do
- it 'combines the attributes of the two relations' do
- join = InnerJoin.new(@relation1, @relation2, @predicate)
- join.attributes.should == (@relation1.attributes | @relation2.attributes).bind(join)
- end
- end
- end
-end
diff --git a/spec/algebra/unit/relations/order_spec.rb b/spec/algebra/unit/relations/order_spec.rb
deleted file mode 100644
index 9fcdffe340..0000000000
--- a/spec/algebra/unit/relations/order_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Order do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe "#==" do
- it "returns true when the Orders are for the same attribute and direction" do
- Ascending.new(@attribute).should == Ascending.new(@attribute)
- end
-
- it "returns false when the Orders are for a diferent direction" do
- Ascending.new(@attribute).should_not == Descending.new(@attribute)
- end
- end
- end
-end
-
diff --git a/spec/algebra/unit/relations/project_spec.rb b/spec/algebra/unit/relations/project_spec.rb
deleted file mode 100644
index 294bffafe9..0000000000
--- a/spec/algebra/unit/relations/project_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Project do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#attributes' do
- before do
- @projection = Project.new(@relation, [@attribute])
- end
-
- it "manufactures attributes associated with the projection relation" do
- @projection.attributes.should == [@attribute].collect { |a| a.bind(@projection) }
- end
- end
-
- describe '#externalizable?' do
- describe 'when the projections are attributes' do
- it 'returns false' do
- Project.new(@relation, [@attribute]).should_not be_externalizable
- end
- end
-
- describe 'when the projections include an aggregation' do
- it "obtains" do
- Project.new(@relation, [@attribute.sum]).should be_externalizable
- end
- end
- end
- end
-end
diff --git a/spec/algebra/unit/relations/relation_spec.rb b/spec/algebra/unit/relations/relation_spec.rb
deleted file mode 100644
index a1ffd901d7..0000000000
--- a/spec/algebra/unit/relations/relation_spec.rb
+++ /dev/null
@@ -1,236 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Relation do
- before do
- @relation = Table.new(:users)
- @attribute1 = @relation[:id]
- @attribute2 = @relation[:name]
- end
-
- describe '[]' do
- describe 'when given an', Attribute do
- it "return the attribute congruent to the provided attribute" do
- @relation[@attribute1].should == @attribute1
- end
- end
-
- describe 'when given a', Symbol, String do
- it "returns the attribute with the same name" do
- check @relation[:id].should == @attribute1
- check @relation['id'].should == @attribute1
- end
- end
- end
-
- describe 'Relation::Operable' do
- describe 'joins' do
- before do
- @predicate = @relation[:id].eq(@relation[:id])
- end
-
- describe '#join' do
- describe 'when given a relation' do
- it "manufactures an inner join operation between those two relations" do
- join = @relation.join(@relation).on(@predicate)
- join.relation1.should == @relation
- join.relation2.should == @relation
- join.predicates.should == [@predicate]
- join.should be_kind_of(InnerJoin)
- end
- end
-
- describe "when given a string" do
- it "manufactures a join operation with the string passed through" do
- arbitrary_string = "ASDF"
-
- join = @relation.join(arbitrary_string)
- join.relation1.should == @relation
- join.relation2.should == arbitrary_string
- join.predicates.should == []
- join.should be_kind_of StringJoin
- end
- end
-
- describe "when given something blank" do
- it "returns self" do
- @relation.join.should == @relation
- end
- end
- end
-
- describe '#outer_join' do
- it "manufactures a left outer join operation between those two relations" do
- join = @relation.outer_join(@relation).on(@predicate)
- join.relation1.should == @relation
- join.relation2.should == @relation
- join.predicates.should == [@predicate]
- join.should be_kind_of OuterJoin
- end
- end
- end
-
- describe '#project' do
- it "manufactures a projection relation" do
- project = @relation.project(@attribute1, @attribute2)
- project.relation.should == @relation
- project.projections.should == [@attribute1, @attribute2]
- project.should be_kind_of Project
- end
-
- describe "when given blank attributes" do
- it "returns self" do
- @relation.project.should == @relation
- end
- end
- end
-
- describe '#alias' do
- it "manufactures an alias relation" do
- @relation.alias.relation.should == Alias.new(@relation).relation
- end
- end
-
- describe '#where' do
- before do
- @predicate = Predicates::Equality.new(@attribute1, @attribute2)
- end
-
- it "manufactures a where relation" do
- where = @relation.where(@predicate)
- where.relation.should == @relation
- where.predicates.should == [@predicate]
- where.should be_kind_of Where
- end
-
- it "accepts arbitrary strings" do
- where = @relation.where("arbitrary")
- where.relation.should == @relation
-
- where.predicates.length.should == 1
- where.predicates.first.value.should == "arbitrary"
-
- where.should be_kind_of Where
- end
-
- describe 'when given a blank predicate' do
- it 'returns self' do
- @relation.where.should == @relation
- end
- end
- end
-
- describe '#order' do
- it "manufactures an order relation" do
- order = @relation.order(@attribute1, @attribute2)
- order.relation.should == @relation
- order.orderings.should == [@attribute1, @attribute2]
- order.should be_kind_of Order
- end
-
- describe 'when given a blank ordering' do
- it 'returns self' do
- @relation.order.should == @relation
- end
- end
- end
-
- describe '#take' do
- it "manufactures a take relation" do
- take = @relation.take(5)
- take.relation.should == @relation
- take.taken.should == 5
- end
-
- describe 'when given a blank number of items' do
- it 'raises error' do
- lambda { @relation.take }.should raise_exception
- end
- end
- end
-
- describe '#skip' do
- it "manufactures a skip relation" do
- skip = @relation.skip(4)
- skip.relation.should == @relation
- skip.skipped.should == 4
- skip.should be_kind_of Skip
- end
-
- describe 'when given a blank number of items' do
- it 'returns self' do
- @relation.skip.should == @relation
- end
- end
- end
-
- describe '#group' do
- it 'manufactures a group relation' do
- group = @relation.group(@attribute1, @attribute2)
- group.relation.should == @relation
- group.groupings.should == [@attribute1, @attribute2]
- group.should be_kind_of Group
- sql = group.to_sql
- sql.should =~ /GROUP BY/
- end
-
- describe 'when given blank groupings' do
- it 'returns self' do
- @relation.group.should == @relation
- end
- end
- end
-
- describe 'relation is writable' do
- describe '#delete' do
- it 'manufactures a deletion relation' do
- Session.start do |s|
- s.should_receive(:delete) do |delete|
- delete.relation.should == @relation
- delete.should be_kind_of Deletion
- end
- @relation.delete
- end
- end
- end
-
- describe '#insert' do
- it 'manufactures an insertion relation' do
- Session.start do |s|
- record = { @relation[:name] => Value.new('carl', @relation) }
- s.should_receive(:create) do |insert|
- insert.relation.should == @relation
- insert.record.should == record
- insert.should be_kind_of Insert
- insert
- end
- @relation.insert(record)
- end
- end
- end
-
- describe '#update' do
- it 'manufactures an update relation' do
- Session.start do |s|
- assignments = { @relation[:name] => Value.new('bob', @relation) }
- s.should_receive(:update) do |update|
- update.relation.should == @relation
- update.assignments.should == assignments
- update.should be_kind_of Update
- update
- end
- @relation.update(assignments)
- end
- end
- end
- end
- end
-
- describe 'is enumerable' do
- it "implements enumerable" do
- @relation.map { |value| value }.should ==
- @relation.session.read(@relation).map { |value| value }
- end
- end
- end
-end
diff --git a/spec/algebra/unit/relations/skip_spec.rb b/spec/algebra/unit/relations/skip_spec.rb
deleted file mode 100644
index e7dea6c1cf..0000000000
--- a/spec/algebra/unit/relations/skip_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Skip do
- before do
- @relation = Table.new(:users)
- @skipped = 4
- end
- end
-end
diff --git a/spec/algebra/unit/relations/take_spec.rb b/spec/algebra/unit/relations/take_spec.rb
deleted file mode 100644
index 3ad8d269f1..0000000000
--- a/spec/algebra/unit/relations/take_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Take do
- before do
- @relation = Table.new(:users)
- @taken = 4
- end
- end
-end
diff --git a/spec/algebra/unit/relations/update_spec.rb b/spec/algebra/unit/relations/update_spec.rb
deleted file mode 100644
index 9ed20a446b..0000000000
--- a/spec/algebra/unit/relations/update_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Update do
- before do
- @relation = Table.new(:users)
- end
- end
-end
diff --git a/spec/algebra/unit/relations/where_spec.rb b/spec/algebra/unit/relations/where_spec.rb
deleted file mode 100644
index 48a8dc5038..0000000000
--- a/spec/algebra/unit/relations/where_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require '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
- pending "This is not true anymore"
- another_predicate = @relation[:name].lt(2)
- Where.new(@relation, @predicate, another_predicate). \
- should == Where.new(Where.new(@relation, another_predicate), @predicate)
- end
- end
- end
-end
diff --git a/spec/algebra/unit/session/session_spec.rb b/spec/algebra/unit/session/session_spec.rb
deleted file mode 100644
index 0aaa031794..0000000000
--- a/spec/algebra/unit/session/session_spec.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Session do
- before do
- @relation = Table.new(:users)
- @session = Session.new
- end
-
- describe '::start' do
- describe '::instance' do
- it "it is a singleton within the started session" do
- Session.start do |session|
- Session.instance.should == session
- end
- end
-
- it "is a singleton across nested sessions" do
- Session.start do |s1|
- outside = Session.instance
- Session.start do |s2|
- Session.instance.should == outside
- end
- end
- end
-
- it "manufactures new sessions outside of the started session" do
- Session.new.should_not == Session.new
- end
- end
- end
-
- describe 'session crud' do
- before do
- @insert = Insert.new(@relation, @relation[:name] => 'nick')
- @update = Update.new(@relation, @relation[:name] => 'nick')
- @delete = Deletion.new(@relation)
- @read = @relation
- end
-
- describe '#create' do
- it "executes an insertion on the connection" do
- @insert.should_receive(:call)
- @session.create(@insert)
- end
- end
-
- describe '#read' do
- it "executes an selection on the connection" do
- @read.should_receive(:call)
- @session.read(@read)
- end
-
- it "is memoized" do
- @read.should_receive(:call).once
- @session.read(@read)
- @session.read(@read)
- end
- end
-
- describe '#update' do
- it "executes an update on the connection" do
- @update.should_receive(:call)
- @session.update(@update)
- end
- end
-
- describe '#delete' do
- it "executes a delete on the connection" do
- @delete.should_receive(:call)
- @session.delete(@delete)
- end
- end
- end
-
- describe 'Transactions' do
- describe '#begin' do
- end
-
- describe '#end' do
- end
- end
- end
-end
diff --git a/spec/arel/attributes/attribute_spec.rb b/spec/attributes/attribute_spec.rb
index faef096792..faef096792 100644
--- a/spec/arel/attributes/attribute_spec.rb
+++ b/spec/attributes/attribute_spec.rb
diff --git a/spec/attributes/boolean_spec.rb b/spec/attributes/boolean_spec.rb
deleted file mode 100644
index 12b243e828..0000000000
--- a/spec/attributes/boolean_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe "Attributes::Boolean" do
-
- before :all do
- @relation = Model.build do |r|
- r.engine Testing::Engine.new
- r.attribute :awesome, Attributes::Boolean
- end
- end
-
- def type_cast(val)
- @relation[:awesome].type_cast(val)
- end
-
- describe "#type_cast" do
- it "returns same value if passed a boolean" do
- val = true
- type_cast(val).should eql(val)
- end
-
- it "returns boolean representation (false) of nil" do
- type_cast(nil).should eql(false)
- end
-
- it "returns boolean representation of 'true', 'false'" do
- type_cast('true').should eql(true)
- type_cast('false').should eql(false)
- end
-
- it "returns boolean representation of :true, :false" do
- type_cast(:true).should eql(true)
- type_cast(:false).should eql(false)
- end
-
- it "returns boolean representation of 0, 1" do
- type_cast(1).should == true
- type_cast(0).should == false
- end
-
- it "calls #to_s on arbitrary objects" do
- obj = Object.new
- obj.extend Module.new { def to_s ; 'true' ; end }
- type_cast(obj).should == true
- end
-
- [ Object.new, 'string', '00.0', 5 ].each do |value|
- it "raises exception when attempting type_cast of non-boolean value #{value.inspect}" do
- lambda do
- type_cast(value)
- end.should raise_error(TypecastError, /could not typecast/)
- end
- end
- end
- end
-end
diff --git a/spec/attributes/float_spec.rb b/spec/attributes/float_spec.rb
deleted file mode 100644
index 3a9a8debbc..0000000000
--- a/spec/attributes/float_spec.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-require 'spec_helper'
-require 'bigdecimal'
-
-module Arel
- describe "Attributes::Float" do
-
- before :all do
- @relation = Model.build do |r|
- r.engine Testing::Engine.new
- r.attribute :percentage, Attributes::Float
- end
- end
-
- def type_cast(val)
- @relation[:percentage].type_cast(val)
- end
-
- describe "#type_cast" do
- it "returns same value if an float" do
- type_cast(24.01).should eql(24.01)
- end
-
- it "returns nil if passed nil" do
- type_cast(nil).should be_nil
- end
-
- it "returns nil if passed empty string" do
- type_cast('').should be_nil
- end
-
- it "returns float representation of a zero string float" do
- type_cast('0').should eql(0.0)
- end
-
- it "returns float representation of a positive string integer" do
- type_cast('24').should eql(24.0)
- end
-
- it "returns float representation of a positive string integer with spaces" do
- type_cast(' 24').should eql(24.0)
- type_cast('24 ').should eql(24.0)
- end
-
- it "returns float representation of a negative string float" do
- type_cast('-24.23').should eql(-24.23)
- end
-
- it "returns float representation of a negative string integer with spaces" do
- type_cast('-24 ').should eql(-24.0)
- type_cast(' -24').should eql(-24.0)
- end
-
- it "returns integer representation of a zero string float" do
- type_cast('0.0').should eql(0.0)
- end
-
- it "returns integer representation of a positive string float" do
- type_cast('24.35').should eql(24.35)
- end
-
- it "returns integer representation of a positive string float with spaces" do
- type_cast(' 24.35').should eql(24.35)
- type_cast('24.35 ').should eql(24.35)
- end
-
- it "returns integer representation of a negative string float" do
- type_cast('-24.35').should eql(-24.35)
- end
-
- it "returns integer representation of a negative string float with spaces" do
- type_cast(' -24.35 ').should eql(-24.35)
- end
-
- it "returns integer representation of a zero string float, with no leading digits" do
- type_cast('.0').should eql(0.0)
- end
-
- it "returns integer representation of a zero string float, with no leading digits with spaces" do
- type_cast(' .0').should eql(0.0)
- end
-
- it "returns integer representation of a positive string float, with no leading digits" do
- type_cast('.41').should eql(0.41)
- end
-
- it "returns integer representation of a zero float" do
- type_cast(0.0).should eql(0.0)
- end
-
- it "returns integer representation of a positive float" do
- type_cast(24.35).should eql(24.35)
- end
-
- it "returns integer representation of a negative float" do
- type_cast(-24.35).should eql(-24.35)
- end
-
- it "returns integer representation of a zero decimal" do
- type_cast(BigDecimal('0.0')).should eql(0.0)
- end
-
- it "returns integer representation of a positive decimal" do
- type_cast(BigDecimal('24.35')).should eql(24.35)
- end
-
- it "returns integer representation of a negative decimal" do
- type_cast(BigDecimal('-24.35')).should eql(-24.35)
- end
-
- [ Object.new, true, '00.0', '0.', 'string' ].each do |value|
- it "raises exception when attempting type_cast of non-numeric value #{value.inspect}" do
- lambda do
- type_cast(value)
- end.should raise_error(TypecastError, /could not typecast/)
- end
- end
- end
- end
-end
diff --git a/spec/attributes/header_spec.rb b/spec/attributes/header_spec.rb
deleted file mode 100644
index 51cba93df3..0000000000
--- a/spec/attributes/header_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe "Header" do
- before :all do
- @relation = Model.build do |r|
- r.attribute :id, Attributes::Integer
- r.attribute :name, Attributes::String
- r.attribute :age, Attributes::Integer
- end
-
- @other = Model.build do |r|
- r.attribute :foo, Attributes::String
- end
-
- @subset = Model.build do |r|
- r.attribute :id, Attributes::Integer
- end
- end
-
- describe "attribute lookup" do
- it "finds attributes by name" do
- @relation.attributes[:name].should == Attributes::String.new(@relation, :name)
- end
-
- it "returns nil if no attribute is found" do
- @relation.attributes[:does_not_exist].should be_nil
- @relation[:does_not_exist].should be_nil
- end
- end
-
- describe "#union" do
- it "keeps all attributes from disjoint headers" do
- (@relation.attributes.union @other.attributes).to_ary.should have(4).items
- end
-
- it "keeps all attributes from both relations even if they seem like subsets" do
- (@relation.attributes.union @subset.attributes).to_ary.should have(4).items
- end
- end
- end
-end
diff --git a/spec/attributes/integer_spec.rb b/spec/attributes/integer_spec.rb
deleted file mode 100644
index 59b7afb2b4..0000000000
--- a/spec/attributes/integer_spec.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-require 'spec_helper'
-require 'bigdecimal'
-
-module Arel
- describe "Attributes::Integer" do
-
- before :all do
- @relation = Model.build do |r|
- r.engine Testing::Engine.new
- r.attribute :age, Attributes::Integer
- end
- end
-
- def type_cast(val)
- @relation[:age].type_cast(val)
- end
-
- describe "#type_cast" do
- it "returns same value if an integer" do
- type_cast(24).should eql(24)
- end
-
- it "returns nil if passed nil" do
- type_cast(nil).should be_nil
- end
-
- it "returns nil if passed empty string" do
- type_cast('').should be_nil
- end
-
- it "returns integer representation of a zero string integer" do
- type_cast('0').should eql(0)
- end
-
- it "returns integer representation of a positive string integer" do
- type_cast('24').should eql(24)
- end
-
- it "returns integer representation of a positive string integer with spaces" do
- type_cast(' 24').should eql(24)
- type_cast('24 ').should eql(24)
- end
-
- it "returns integer representation of a negative string integer" do
- type_cast('-24').should eql(-24)
- end
-
- it "returns integer representation of a negative string integer with spaces" do
- type_cast('-24 ').should eql(-24)
- type_cast(' -24').should eql(-24)
- end
-
- it "returns integer representation of a zero string float" do
- type_cast('0.0').should eql(0)
- end
-
- it "returns integer representation of a positive string float" do
- type_cast('24.35').should eql(24)
- end
-
- it "returns integer representation of a positive string float with spaces" do
- type_cast(' 24.35').should eql(24)
- type_cast('24.35 ').should eql(24)
- end
-
- it "returns integer representation of a negative string float" do
- type_cast('-24.35').should eql(-24)
- end
-
- it "returns integer representation of a negative string float with spaces" do
- type_cast(' -24.35 ').should eql(-24)
- end
-
- it "returns integer representation of a zero string float, with no leading digits" do
- type_cast('.0').should eql(0)
- end
-
- it "returns integer representation of a zero string float, with no leading digits with spaces" do
- type_cast(' .0').should eql(0)
- end
-
- it "returns integer representation of a positive string float, with no leading digits" do
- type_cast('.41').should eql(0)
- end
-
- it "returns integer representation of a zero float" do
- type_cast(0.0).should eql(0)
- end
-
- it "returns integer representation of a positive float" do
- type_cast(24.35).should eql(24)
- end
-
- it "returns integer representation of a negative float" do
- type_cast(-24.35).should eql(-24)
- end
-
- it "returns integer representation of a zero decimal" do
- type_cast(BigDecimal('0.0')).should eql(0)
- end
-
- it "returns integer representation of a positive decimal" do
- type_cast(BigDecimal('24.35')).should eql(24)
- end
-
- it "returns integer representation of a negative decimal" do
- type_cast(BigDecimal('-24.35')).should eql(-24)
- end
-
- [ Object.new, true, '00.0', '0.', 'string' ].each do |value|
- it "raises exception when attempting type_cast of non-numeric value #{value.inspect}" do
- lambda do
- type_cast(value)
- end.should raise_error(TypecastError, /could not typecast/)
- end
- end
- end
- end
-end
diff --git a/spec/attributes/string_spec.rb b/spec/attributes/string_spec.rb
deleted file mode 100644
index 487d82249d..0000000000
--- a/spec/attributes/string_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'spec_helper'
-require 'bigdecimal'
-
-module Arel
- describe "Attributes::String" do
-
- before :all do
- @relation = Model.build do |r|
- r.engine Testing::Engine.new
- r.attribute :name, Attributes::String
- end
- end
-
- def type_cast(val)
- @relation[:name].type_cast(val)
- end
-
- describe "#type_cast" do
- it "returns same value if passed a String" do
- val = "hell"
- type_cast(val).should eql(val)
- end
-
- it "returns nil if passed nil" do
- type_cast(nil).should be_nil
- end
-
- it "returns String representation of Symbol" do
- type_cast(:hello).should == "hello"
- end
-
- it "returns string representation of Integer" do
- type_cast(1).should == '1'
- end
-
- it "calls #to_s on arbitrary objects" do
- obj = Object.new
- obj.extend Module.new { def to_s ; 'hello' ; end }
- type_cast(obj).should == 'hello'
- end
- end
- end
-end
diff --git a/spec/attributes/time_spec.rb b/spec/attributes/time_spec.rb
deleted file mode 100644
index 15384e2073..0000000000
--- a/spec/attributes/time_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'spec_helper'
-require 'bigdecimal'
-
-module Arel
- describe "Attributes::Time" do
-
- before :all do
- @relation = Model.build do |r|
- r.engine Testing::Engine.new
- r.attribute :created_at, Attributes::Time
- end
- end
-
- def type_cast(val)
- @relation[:created_at].type_cast(val)
- end
-
- describe "#type_cast" do
- it "works" do
- pending
- end
- end
- end
-end
diff --git a/spec/arel/attributes_spec.rb b/spec/attributes_spec.rb
index 8b437dff9b..8b437dff9b 100644
--- a/spec/arel/attributes_spec.rb
+++ b/spec/attributes_spec.rb
diff --git a/spec/arel/crud_spec.rb b/spec/crud_spec.rb
index 5c03857284..5c03857284 100644
--- a/spec/arel/crud_spec.rb
+++ b/spec/crud_spec.rb
diff --git a/spec/arel/delete_manager_spec.rb b/spec/delete_manager_spec.rb
index 74496c58c6..74496c58c6 100644
--- a/spec/arel/delete_manager_spec.rb
+++ b/spec/delete_manager_spec.rb
diff --git a/spec/engines/memory/integration/joins/cross_engine_spec.rb b/spec/engines/memory/integration/joins/cross_engine_spec.rb
deleted file mode 100644
index 4646eeba2f..0000000000
--- a/spec/engines/memory/integration/joins/cross_engine_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @users = Array.new([
- [1, 'bryan' ],
- [2, 'emilio' ],
- [3, 'nick']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- @photos = Table.new(:photos)
- @photos.delete
- @photos.insert(@photos[:id] => 1, @photos[:user_id] => 1, @photos[:camera_id] => 6)
- @photos.insert(@photos[:id] => 2, @photos[:user_id] => 2, @photos[:camera_id] => 42)
- # Oracle adapter returns database integers as Ruby integers and not strings
- # So does the FFI sqlite library
- db_int_return = @photos.project(@photos[:camera_id]).first.tuple.first
- @adapter_returns_integer = db_int_return.is_a?(String) ? false : true
- end
-
- describe 'when the in memory relation is on the left' do
- it 'joins across engines' do
- @users \
- .join(@photos) \
- .on(@users[:id].eq(@photos[:user_id])) \
- .project(@users[:name], @photos[:camera_id]) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 2
- [
- ['bryan', @adapter_returns_integer ? 6 : '6'],
- ['emilio', @adapter_returns_integer ? 42 : '42']
- ].zip(rows).each do |tuple, row|
- row.relation.should == relation
- row.tuple.should == tuple
- end
- end
- end
- end
-
- describe 'when the in memory relation is on the right' do
- it 'joins across engines' do
- @photos \
- .join(@users) \
- .on(@users[:id].eq(@photos[:user_id])) \
- .project(@users[:name], @photos[:camera_id]) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 2
- [
- ['bryan', @adapter_returns_integer ? 6 : '6'],
- ['emilio', @adapter_returns_integer ? 42 : '42']
- ].zip(rows).each do |tuple, row|
- row.relation.should == relation
- row.tuple.should == tuple
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/array_spec.rb b/spec/engines/memory/unit/relations/array_spec.rb
deleted file mode 100644
index 65bfb4025f..0000000000
--- a/spec/engines/memory/unit/relations/array_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Array do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#attributes' do
- it 'manufactures attributes corresponding to the names given on construction' do
- @relation.attributes.should == [
- Attribute.new(@relation, :id),
- Attribute.new(@relation, :name)
- ]
- end
- end
-
- describe '#call' do
- it "manufactures an array of hashes of attributes to values" do
- rows = @relation.call
- rows.length.should == 3
- @relation.array.zip(rows).each do |tuple, row|
- row.relation.should == @relation
- row.tuple.should == tuple
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/insert_spec.rb b/spec/engines/memory/unit/relations/insert_spec.rb
deleted file mode 100644
index 987e708e0b..0000000000
--- a/spec/engines/memory/unit/relations/insert_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Insert do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#call' do
- it "manufactures an array of hashes of attributes to values" do
- @relation \
- .insert(@relation[:id] => 4, @relation[:name] => 'guinea fowl') \
- do |relation|
- relation.should == [
- Row.new(relation, [1, 'duck']),
- Row.new(relation, [2, 'duck']),
- Row.new(relation, [3, 'goose']),
- Row.new(relation, [4, 'guinea fowl'])
- ]
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/join_spec.rb b/spec/engines/memory/unit/relations/join_spec.rb
deleted file mode 100644
index 93379985cb..0000000000
--- a/spec/engines/memory/unit/relations/join_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @relation1 = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- @relation2 = @relation1.alias
- end
-
- describe InnerJoin do
- describe '#call' do
- it 'combines the two tables where the predicate obtains' do
- @relation1 \
- .join(@relation2) \
- .on(@relation1[:id].eq(@relation2[:id])) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 3
- @relation1.array.zip(rows).each do |tuple, row|
- row.relation.should == relation
- row.tuple.should == (tuple * 2)
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/order_spec.rb b/spec/engines/memory/unit/relations/order_spec.rb
deleted file mode 100644
index 86c59ffc46..0000000000
--- a/spec/engines/memory/unit/relations/order_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Order do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#call' do
- it 'sorts the relation with the provided ordering' do
- @relation \
- .order(@relation[:id].desc) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 3
- @relation.array.reverse.zip(rows) do |tuple, row|
- row.relation.should == relation
- row.tuple.should == tuple
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/project_spec.rb b/spec/engines/memory/unit/relations/project_spec.rb
deleted file mode 100644
index cf20573fd2..0000000000
--- a/spec/engines/memory/unit/relations/project_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Project do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#call' do
- it 'retains only the attributes that are provided' do
- @relation \
- .project(@relation[:id]) \
- .tap do |relation|
- rows = relation.call
- @relation.array.zip(rows) do |tuple, row|
- row.relation.should == relation
- row.tuple.should == [tuple.first]
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/skip_spec.rb b/spec/engines/memory/unit/relations/skip_spec.rb
deleted file mode 100644
index abb87d2e38..0000000000
--- a/spec/engines/memory/unit/relations/skip_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Skip do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#call' do
- it 'removes the first n rows' do
- @relation \
- .skip(1) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 2
- one, two = *rows
-
- one.relation.should == relation
- one.tuple.should == [2, 'duck']
-
- two.relation.should == relation
- two.tuple.should == [3, 'goose']
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/take_spec.rb b/spec/engines/memory/unit/relations/take_spec.rb
deleted file mode 100644
index b7e49ddca6..0000000000
--- a/spec/engines/memory/unit/relations/take_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Take do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#call' do
- it 'removes the rows after the first n' do
- @relation \
- .take(2) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 2
- rows.each_with_index do |row, i|
- row.relation.should == relation
- row.tuple.should == [i + 1, 'duck']
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/memory/unit/relations/where_spec.rb b/spec/engines/memory/unit/relations/where_spec.rb
deleted file mode 100644
index c75fe10f1b..0000000000
--- a/spec/engines/memory/unit/relations/where_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Where do
- before do
- @relation = Array.new([
- [1, 'duck' ],
- [2, 'duck' ],
- [3, 'goose']
- ], [[:id, Attributes::Integer], [:name, Attributes::String]])
- end
-
- describe '#call' do
- it 'filters the relation with the provided predicate' do
- @relation \
- .where(@relation[:id].lt(3)) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 2
- rows.each_with_index do |row, i|
- row.relation.should == relation
- row.tuple.should == [i + 1, 'duck']
- end
- end
- end
-
- describe 'when filtering a where relation' do
- it 'further filters the already-filtered relation with the provided predicate' do
- @relation \
- .where(@relation[:id].gt(1)) \
- .where(@relation[:id].lt(3)) \
- .tap do |relation|
- rows = relation.call
- rows.length.should == 1
- row = rows.first
- row.relation.should == relation
- row.tuple.should == [2, 'duck']
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/integration/joins/with_adjacency_spec.rb b/spec/engines/sql/integration/joins/with_adjacency_spec.rb
deleted file mode 100644
index 1a0e28838d..0000000000
--- a/spec/engines/sql/integration/joins/with_adjacency_spec.rb
+++ /dev/null
@@ -1,258 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @relation1 = Table(:users)
- @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
- sql = @relation1.join(@relation2).on(@predicate).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`
- FROM `users`
- INNER JOIN `users` `users_2`
- ON `users`.`id` = `users_2`.`id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME"
- FROM "USERS"
- INNER JOIN "USERS" "USERS_2"
- ON "USERS"."ID" = "USERS_2"."ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name"
- FROM "users"
- INNER JOIN "users" "users_2"
- ON "users"."id" = "users_2"."id"
- })
- end
- end
-
- describe 'when joining with a where on the same relation' do
- it 'manufactures sql aliasing the tables properly' do
- sql = @relation1 \
- .join(@relation2.where(@relation2[:id].eq(1))) \
- .on(@predicate) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`
- FROM `users`
- INNER JOIN `users` `users_2`
- ON `users`.`id` = `users_2`.`id` AND `users_2`.`id` = 1
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME"
- FROM "USERS"
- INNER JOIN "USERS" "USERS_2"
- ON "USERS"."ID" = "USERS_2"."ID" AND "USERS_2"."ID" = 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name"
- FROM "users"
- INNER JOIN "users" "users_2"
- ON "users"."id" = "users_2"."id" AND "users_2"."id" = 1
- })
- end
- 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
-
- sql = @relation1 \
- .join(relation2) \
- .on(relation2[:id].eq(@relation1[:id])) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`
- FROM `users`
- INNER JOIN `users` `users_2`
- ON `users_2`.`id` = `users`.`id` AND `users_2`.`id` = 1
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME"
- FROM "USERS"
- INNER JOIN "USERS" "USERS_2"
- ON "USERS_2"."ID" = "USERS"."ID" AND "USERS_2"."ID" = 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name"
- FROM "users"
- INNER JOIN "users" "users_2"
- ON "users_2"."id" = "users"."id" AND "users_2"."id" = 1
- })
- end
- 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
- sql = @relation1 \
- .join(@relation2 \
- .join(@relation3) \
- .on(@relation2[:id].eq(@relation3[:id]))) \
- .on(@relation1[:id].eq(@relation2[:id])) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`, `users_3`.`id`, `users_3`.`name`
- FROM `users`
- INNER JOIN `users` `users_2`
- ON `users`.`id` = `users_2`.`id`
- INNER JOIN `users` `users_3`
- ON `users_2`.`id` = `users_3`.`id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME", "USERS_3"."ID", "USERS_3"."NAME"
- FROM "USERS"
- INNER JOIN "USERS" "USERS_2"
- ON "USERS"."ID" = "USERS_2"."ID"
- INNER JOIN "USERS" "USERS_3"
- ON "USERS_2"."ID" = "USERS_3"."ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name", "users_3"."id", "users_3"."name"
- FROM "users"
- INNER JOIN "users" "users_2"
- ON "users"."id" = "users_2"."id"
- INNER JOIN "users" "users_3"
- ON "users_2"."id" = "users_3"."id"
- })
- end
- end
- end
-
- describe 'when joining right-associatively' do
- it 'manufactures sql aliasing the tables properly' do
- sql = @relation1 \
- .join(@relation2).on(@relation1[:id].eq(@relation2[:id])) \
- .join(@relation3).on(@relation2[:id].eq(@relation3[:id])) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `users_2`.`id`, `users_2`.`name`, `users_3`.`id`, `users_3`.`name`
- FROM `users`
- INNER JOIN `users` `users_2`
- ON `users`.`id` = `users_2`.`id`
- INNER JOIN `users` `users_3`
- ON `users_2`.`id` = `users_3`.`id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "USERS_2"."ID", "USERS_2"."NAME", "USERS_3"."ID", "USERS_3"."NAME"
- FROM "USERS"
- INNER JOIN "USERS" "USERS_2"
- ON "USERS"."ID" = "USERS_2"."ID"
- INNER JOIN "USERS" "USERS_3"
- ON "USERS_2"."ID" = "USERS_3"."ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "users_2"."id", "users_2"."name", "users_3"."id", "users_3"."name"
- FROM "users"
- INNER JOIN "users" "users_2"
- ON "users"."id" = "users_2"."id"
- INNER JOIN "users" "users_3"
- ON "users_2"."id" = "users_3"."id"
- })
- end
- end
- 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
- @relation1 \
- .join(@relation2) \
- .on(@predicate) \
- .should disambiguate_attributes(@relation1[:id], @relation2[:id])
- end
-
- 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.where(@predicate)
- compound2 = compound1.alias
- compound1 \
- .join(compound2) \
- .on(@predicate) \
- .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 \
- .where(@predicate) \
- .where(@predicate) \
- .join(@relation2) \
- .on(@predicate) \
- .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 \
- .join( \
- @relation2 \
- .where(@predicate) \
- .where(@predicate) \
- .where(@predicate)) \
- .on(@predicate) \
- .should disambiguate_attributes(@relation1[:id], @relation2[:id])
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/integration/joins/with_aggregations_spec.rb b/spec/engines/sql/integration/joins/with_aggregations_spec.rb
deleted file mode 100644
index 62e1b8baea..0000000000
--- a/spec/engines/sql/integration/joins/with_aggregations_spec.rb
+++ /dev/null
@@ -1,221 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @relation1 = Table(:users)
- @relation2 = Table(: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
- sql = @relation1.join(@relation2.take(3)).on(@predicate).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos_external`.`id`, `photos_external`.`user_id`, `photos_external`.`camera_id`
- FROM `users`
- INNER JOIN (SELECT `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id` FROM `photos` LIMIT 3) `photos_external`
- ON `users`.`id` = `photos_external`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS_EXTERNAL"."ID", "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CAMERA_ID"
- FROM "USERS"
- INNER JOIN (SELECT "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID" FROM "PHOTOS" WHERE ROWNUM <= 3) "PHOTOS_EXTERNAL"
- ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos_external"."id", "photos_external"."user_id", "photos_external"."camera_id"
- FROM "users"
- INNER JOIN (SELECT "photos"."id", "photos"."user_id", "photos"."camera_id" FROM "photos" LIMIT 3) "photos_external"
- ON "users"."id" = "photos_external"."user_id"
- })
- end
- end
-
- describe 'with the aggregation on the right' do
- it 'manufactures sql joining the left table to a derived table' do
- sql = @relation1.join(@aggregation).on(@predicate).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos_external`.`user_id`, `photos_external`.`cnt`
- FROM `users`
- INNER JOIN (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` GROUP BY `photos`.`user_id`) `photos_external`
- ON `users`.`id` = `photos_external`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT"
- FROM "USERS"
- INNER JOIN (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL"
- ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos_external"."user_id", "photos_external"."cnt"
- FROM "users"
- INNER JOIN (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" GROUP BY "photos"."user_id") "photos_external"
- ON "users"."id" = "photos_external"."user_id"
- })
- end
- end
- end
-
- describe 'with the aggregation on the left' do
- it 'manufactures sql joining the right table to a derived table' do
- sql = @aggregation.join(@relation1).on(@predicate).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `photos_external`.`user_id`, `photos_external`.`cnt`, `users`.`id`, `users`.`name`
- FROM (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` GROUP BY `photos`.`user_id`) `photos_external`
- INNER JOIN `users`
- ON `users`.`id` = `photos_external`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT", "USERS"."ID", "USERS"."NAME"
- FROM (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL"
- INNER JOIN "USERS"
- ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "photos_external"."user_id", "photos_external"."cnt", "users"."id", "users"."name"
- FROM (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" GROUP BY "photos"."user_id") "photos_external"
- INNER JOIN "users"
- ON "users"."id" = "photos_external"."user_id"
- })
- end
- end
- end
-
- describe 'with the aggregation on both sides' do
- it 'it properly aliases the aggregations' do
- aggregation2 = @aggregation.alias
- sql = @aggregation.join(aggregation2).on(aggregation2[:user_id].eq(@aggregation[:user_id])).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `photos_external`.`user_id`, `photos_external`.`cnt`, `photos_external_2`.`user_id`, `photos_external_2`.`cnt`
- FROM (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` GROUP BY `photos`.`user_id`) `photos_external`
- INNER JOIN (SELECT `photos`.`user_id`, COUNT(`photos`.`id`) AS `cnt` FROM `photos` GROUP BY `photos`.`user_id`) `photos_external_2`
- ON `photos_external_2`.`user_id` = `photos_external`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."CNT", "PHOTOS_EXTERNAL_2"."USER_ID", "PHOTOS_EXTERNAL_2"."CNT"
- FROM (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL"
- INNER JOIN (SELECT "PHOTOS"."USER_ID", COUNT("PHOTOS"."ID") AS "CNT" FROM "PHOTOS" GROUP BY "PHOTOS"."USER_ID") "PHOTOS_EXTERNAL_2"
- ON "PHOTOS_EXTERNAL_2"."USER_ID" = "PHOTOS_EXTERNAL"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "photos_external"."user_id", "photos_external"."cnt", "photos_external_2"."user_id", "photos_external_2"."cnt"
- FROM (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" GROUP BY "photos"."user_id") "photos_external"
- INNER JOIN (SELECT "photos"."user_id", COUNT("photos"."id") AS "cnt" FROM "photos" GROUP BY "photos"."user_id") "photos_external_2"
- ON "photos_external_2"."user_id" = "photos_external"."user_id"
- })
- end
- end
- end
-
- describe 'when the aggration has a where' do
- describe 'with the aggregation on the left' do
- it "manufactures sql keeping wheres on the aggregation within the derived table" do
- sql = @relation1.join(@aggregation.where(@aggregation[:user_id].eq(1))).on(@predicate).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos_external`.`user_id`, `photos_external`.`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`) `photos_external`
- ON `users`.`id` = `photos_external`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."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") "PHOTOS_EXTERNAL"
- ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos_external"."user_id", "photos_external"."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") "photos_external"
- ON "users"."id" = "photos_external"."user_id"
- })
- end
- end
- end
-
- describe 'with the aggregation on the right' do
- it "manufactures sql keeping wheres on the aggregation within the derived table" do
- sql = @aggregation.where(@aggregation[:user_id].eq(1)).join(@relation1).on(@predicate).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `photos_external`.`user_id`, `photos_external`.`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`) `photos_external`
- INNER JOIN `users`
- ON `users`.`id` = `photos_external`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "PHOTOS_EXTERNAL"."USER_ID", "PHOTOS_EXTERNAL"."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") "PHOTOS_EXTERNAL"
- INNER JOIN "USERS"
- ON "USERS"."ID" = "PHOTOS_EXTERNAL"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "photos_external"."user_id", "photos_external"."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") "photos_external"
- INNER JOIN "users"
- ON "users"."id" = "photos_external"."user_id"
- })
- end
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/integration/joins/with_compounds_spec.rb b/spec/engines/sql/integration/joins/with_compounds_spec.rb
deleted file mode 100644
index 65fe49d128..0000000000
--- a/spec/engines/sql/integration/joins/with_compounds_spec.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @relation1 = Table(:users)
- @relation2 = Table(: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
- it 'does not escape the string' do
- sql = @relation1 \
- .join(@relation2.where("asdf")) \
- .on(@predicate) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
- FROM `users`
- INNER JOIN `photos`
- ON `users`.`id` = `photos`.`user_id` AND asdf
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
- FROM "USERS"
- INNER JOIN "PHOTOS"
- ON "USERS"."ID" = "PHOTOS"."USER_ID" AND asdf
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
- FROM "users"
- INNER JOIN "photos"
- ON "users"."id" = "photos"."user_id" AND asdf
- })
- end
- 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
- sql = @relation1 \
- .where(@relation1[:id].eq(1)) \
- .join(@relation2) \
- .on(@predicate) \
- .where(@relation1[:id].eq(1)) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
- FROM `users`
- INNER JOIN `photos`
- ON `users`.`id` = `photos`.`user_id`
- WHERE `users`.`id` = 1
- AND `users`.`id` = 1
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
- FROM "USERS"
- INNER JOIN "PHOTOS"
- ON "USERS"."ID" = "PHOTOS"."USER_ID"
- WHERE "USERS"."ID" = 1
- AND "USERS"."ID" = 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
- FROM "users"
- INNER JOIN "photos"
- ON "users"."id" = "photos"."user_id"
- WHERE "users"."id" = 1
- AND "users"."id" = 1
- })
- end
- end
- end
-
- describe 'and the compound is a group' do
- it 'manufactures sql disambiguating the tables' do
- sql = @relation1 \
- .join(@relation2) \
- .on(@predicate) \
- .group(@relation1[:id]) \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
- FROM `users`
- INNER JOIN `photos`
- ON `users`.`id` = `photos`.`user_id`
- GROUP BY `users`.`id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
- FROM "USERS"
- INNER JOIN "PHOTOS"
- ON "USERS"."ID" = "PHOTOS"."USER_ID"
- GROUP BY "USERS"."ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
- FROM "users"
- INNER JOIN "photos"
- ON "users"."id" = "photos"."user_id"
- GROUP BY "users"."id"
- })
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/engine_spec.rb b/spec/engines/sql/unit/engine_spec.rb
deleted file mode 100644
index 9d3c41ccc0..0000000000
--- a/spec/engines/sql/unit/engine_spec.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-require 'spec_helper'
-
-module Arel
- FakeAR = Struct.new(:connection)
- class FakeConnection < Struct.new :called
- def initialize c = []; super; end
-
- def method_missing name, *args, &block
- called << [name, args, block]
- end
- end
-
- describe Sql::Engine do
- before do
- @users = Table.new(:users)
- @users.delete
- end
-
- describe "method missing" do
- it "should ask for a connection" do
- conn = FakeConnection.new
- ar = FakeAR.new conn
- engine = Arel::Sql::Engine.new ar
-
- ar.connection = nil
- lambda { engine.foo }.should raise_error
- end
- end
-
- describe "CRUD" do
- describe "#create" do
- it "inserts into the relation" do
- @users.insert @users[:name] => "Bryan"
- @users.first[@users[:name]].should == "Bryan"
- end
- end
-
- describe "#read" do
- it "reads from the relation" do
- @users.insert @users[:name] => "Bryan"
-
- @users.each do |row|
- row[@users[:name]].should == "Bryan"
- end
- end
- end
-
- describe "#update" do
- it "updates the relation" do
- @users.insert @users[:name] => "Nick"
- @users.update @users[:name] => "Bryan"
- @users.first[@users[:name]].should == "Bryan"
- end
- end
-
- describe "#delete" do
- it "deletes from the relation" do
- @users.insert @users[:name] => "Bryan"
- @users.delete
- @users.first.should == nil
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/predicates/binary_spec.rb b/spec/engines/sql/unit/predicates/binary_spec.rb
deleted file mode 100644
index 72c8e44888..0000000000
--- a/spec/engines/sql/unit/predicates/binary_spec.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Binary do
- class ConcreteBinary < Binary
- def predicate_sql
- "<=>"
- end
- end
-
- before do
- @relation = Arel::Table.new(:users)
- @attribute1 = @relation[:id]
- @attribute2 = @relation[:name]
- end
-
- describe "with compound predicates" do
- before do
- @operand1 = ConcreteBinary.new(@attribute1, 1)
- @operand2 = ConcreteBinary.new(@attribute2, "name")
- end
-
- describe Or do
- describe "#to_sql" do
- it "manufactures sql with an OR operation" do
- sql = Or.new(@operand1, @operand2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{(`users`.`id` <=> 1 OR `users`.`name` <=> 'name')})
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{("users"."id" <=> 1 OR "users"."name" <=> E'name')})
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{("users"."id" <=> 1 OR "users"."name" <=> 'name')})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{("USERS"."ID" <=> 1 OR "USERS"."NAME" <=> 'name')})
- end
- end
- end
- end
-
- describe And do
- describe "#to_sql" do
- it "manufactures sql with an AND operation" do
- sql = And.new(@operand1, @operand2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{(`users`.`id` <=> 1 AND `users`.`name` <=> 'name')})
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{("users"."id" <=> 1 AND "users"."name" <=> 'name')})
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{("users"."id" <=> 1 AND "users"."name" <=> E'name')})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{("USERS"."ID" <=> 1 AND "USERS"."NAME" <=> 'name')})
- end
- end
- end
- end
- end
-
- describe '#to_sql' do
- describe 'when relating two attributes' do
- it 'manufactures sql with a binary operation' do
- sql = ConcreteBinary.new(@attribute1, @attribute2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` <=> `users`.`name`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" <=> "USERS"."NAME"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" <=> "users"."name"})
- end
- end
- end
-
- describe 'when relating an attribute and a value' do
- before do
- @value = "1-asdf"
- end
-
- describe 'when relating to an integer attribute' do
- it 'formats values as integers' do
- sql = ConcreteBinary.new(@attribute1, @value).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` <=> 1})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" <=> 1})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" <=> 1})
- end
- end
- end
-
- describe 'when relating to a string attribute' do
- it 'formats values as strings' do
- sql = ConcreteBinary.new(@attribute2, @value).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`name` <=> '1-asdf'})
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{"users"."name" <=> '1-asdf'})
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{"users"."name" <=> E'1-asdf'})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."NAME" <=> '1-asdf'})
- end
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/predicates/equality_spec.rb b/spec/engines/sql/unit/predicates/equality_spec.rb
deleted file mode 100644
index bfd61185f2..0000000000
--- a/spec/engines/sql/unit/predicates/equality_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Equality do
- before do
- @relation1 = Arel::Table.new(:users)
- @relation2 = Arel::Table.new(:photos)
- @attribute1 = @relation1[:id]
- @attribute2 = @relation2[:user_id]
- end
-
- describe '#to_sql' do
- describe 'when relating to a non-nil value' do
- it "manufactures an equality predicate" do
- sql = Equality.new(@attribute1, @attribute2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` = `photos`.`user_id`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" = "PHOTOS"."USER_ID"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" = "photos"."user_id"})
- end
- end
- end
-
- describe 'when relation to a nil value' do
- before do
- @nil = nil
- end
-
- it "manufactures an is null predicate" do
- sql = Equality.new(@attribute1, @nil).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IS NULL})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IS NULL})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IS NULL})
- end
- end
- end
-
- describe "when relating to a nil Value" do
- it "manufactures an IS NULL predicate" do
- value = nil.bind(@relation1)
- sql = Equality.new(@attribute1, value).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IS NULL})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IS NULL})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IS NULL})
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/predicates/in_spec.rb b/spec/engines/sql/unit/predicates/in_spec.rb
deleted file mode 100644
index 933e33fe99..0000000000
--- a/spec/engines/sql/unit/predicates/in_spec.rb
+++ /dev/null
@@ -1,179 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe In do
- before do
- @relation = Arel::Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#to_sql' do
- describe 'when relating to an array' do
- describe 'when the array\'s elements are the same type as the attribute' do
- before do
- @array = [1, 2, 3]
- end
-
- it 'manufactures sql with a comma separated list' do
- sql = In.new(@attribute, @array).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IN (1, 2, 3)})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IN (1, 2, 3)})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IN (1, 2, 3)})
- end
- end
- end
-
- describe 'when the array\'s elements are not same type as the attribute' do
- before do
- @array = ['1-asdf', 2, 3]
- end
-
- it 'formats values in the array as the type of the attribute' do
- sql = In.new(@attribute, @array).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IN (1, 2, 3)})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IN (1, 2, 3)})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IN (1, 2, 3)})
- end
- end
- end
-
- describe 'when the array is empty' do
- before do
- @array = []
- end
-
- it 'manufactures sql with a comma separated list' do
- sql = In.new(@attribute, @array).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IN (NULL)})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IN (NULL)})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IN (NULL)})
- end
- end
- end
-
- end
-
- describe 'when relating to a range' do
- before do
- @range = 1..2
- end
-
- it 'manufactures sql with a between' do
- sql = In.new(@attribute, @range).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` BETWEEN 1 AND 2})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" BETWEEN 1 AND 2})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" BETWEEN 1 AND 2})
- end
- end
- end
-
- describe 'when relating to a range with an excluded end' do
- before do
- @range = 1...3
- end
-
- it 'manufactures sql with a >= and <' do
- sql = In.new(@attribute, @range).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{(`users`.`id` >= 1 AND `users`.`id` < 3)})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{("USERS"."ID" >= 1 AND "USERS"."ID" < 3)})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{("users"."id" >= 1 AND "users"."id" < 3)})
- end
- end
- end
-
- describe 'when relating to a time range' do
- before do
- @relation = Arel::Table.new(:developers)
- @attribute = @relation[:created_at]
- @range = Time.mktime(2010, 01, 01)..Time.mktime(2010, 02, 01)
- end
-
- it 'manufactures sql with a between' do
- sql = In.new(@attribute, @range).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`developers`.`created_at` BETWEEN '2010-01-01 00:00:00' AND '2010-02-01 00:00:00'})
- end
-
- adapter_is :sqlite3 do
- sql.should match(/"developers"."created_at" BETWEEN '2010-01-01 00:00:00(?:\.\d+)' AND '2010-02-01 00:00:00(?:\.\d+)'/)
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{"developers"."created_at" BETWEEN '2010-01-01 00:00:00.000000' AND '2010-02-01 00:00:00.000000'})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"DEVELOPERS"."CREATED_AT" BETWEEN TO_TIMESTAMP('2010-01-01 00:00:00:000000','YYYY-MM-DD HH24:MI:SS:FF6') AND TO_TIMESTAMP('2010-02-01 00:00:00:000000','YYYY-MM-DD HH24:MI:SS:FF6')})
- end
- end
- end
-
- describe 'when relating to a relation' do
- it 'manufactures sql with a subselect' do
- sql = In.new(@attribute, @relation).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- `users`.`id` IN (SELECT `users`.`id`, `users`.`name` FROM `users`)
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- "USERS"."ID" IN (SELECT "USERS"."ID", "USERS"."NAME" FROM "USERS")
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- "users"."id" IN (SELECT "users"."id", "users"."name" FROM "users")
- })
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/predicates/noteq_spec.rb b/spec/engines/sql/unit/predicates/noteq_spec.rb
deleted file mode 100644
index ed24627323..0000000000
--- a/spec/engines/sql/unit/predicates/noteq_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Equality do
- before do
- @relation1 = Arel::Table.new(:users)
- @relation2 = Arel::Table.new(:photos)
- @attribute1 = @relation1[:id]
- @attribute2 = @relation2[:user_id]
- end
-
- describe '#to_sql' do
- describe 'when relating to a non-nil value' do
- it "manufactures a not predicate" do
- sql = Inequality.new(@attribute1, @attribute2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` != `photos`.`user_id`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" != "PHOTOS"."USER_ID"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" != "photos"."user_id"})
- end
- end
- end
-
- describe 'when relation to a nil value' do
- before do
- @nil = nil
- end
-
- it "manufactures an is null predicate" do
- sql = Inequality.new(@attribute1, @nil).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IS NOT NULL})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IS NOT NULL})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IS NOT NULL})
- end
- end
- end
-
- describe "when relating to a nil Value" do
- it "manufactures an IS NULL predicate" do
- value = nil.bind(@relation1)
- sql = Inequality.new(@attribute1, value).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id` IS NOT NULL})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID" IS NOT NULL})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id" IS NOT NULL})
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/predicates/predicates_spec.rb b/spec/engines/sql/unit/predicates/predicates_spec.rb
deleted file mode 100644
index e6130cf267..0000000000
--- a/spec/engines/sql/unit/predicates/predicates_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Predicates
- describe Predicate do
- before do
- @relation = Arel::Table.new(:users)
- @attribute1 = @relation[:id]
- @attribute2 = @relation[:name]
- @operand1 = Arel::Predicates::Equality.new(@attribute1, 1)
- @operand2 = Arel::Predicates::Equality.new(@attribute2, "name")
- end
-
- describe "when being combined with another predicate with AND logic" do
- describe "#to_sql" do
- it "manufactures sql with an AND operation" do
- sql = @operand1.and(@operand2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- (`users`.`id` = 1 AND `users`.`name` = 'name')
- })
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{
- ("users"."id" = 1 AND "users"."name" = 'name')
- })
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{
- ("users"."id" = 1 AND "users"."name" = E'name')
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- ("USERS"."ID" = 1 AND "USERS"."NAME" = 'name')
- })
- end
- end
- end
- end
-
- describe "when being combined with another predicate with OR logic" do
- describe "#to_sql" do
- it "manufactures sql with an OR operation" do
- sql = @operand1.or(@operand2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- (`users`.`id` = 1 OR `users`.`name` = 'name')
- })
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{
- ("users"."id" = 1 OR "users"."name" = 'name')
- })
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{
- ("users"."id" = 1 OR "users"."name" = E'name')
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- ("USERS"."ID" = 1 OR "USERS"."NAME" = 'name')
- })
- end
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/primitives/attribute_spec.rb b/spec/engines/sql/unit/primitives/attribute_spec.rb
deleted file mode 100644
index 9f864dd3a1..0000000000
--- a/spec/engines/sql/unit/primitives/attribute_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Attribute do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#column' do
- it "returns the corresponding column in the relation" do
- @attribute.column.should == @relation.column_for(@attribute)
- end
- end
-
- describe '#to_sql' do
- describe 'for a simple attribute' do
- it "manufactures sql with an alias" do
- sql = @attribute.to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{`users`.`id`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{"USERS"."ID"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{"users"."id"})
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/primitives/expression_spec.rb b/spec/engines/sql/unit/primitives/expression_spec.rb
deleted file mode 100644
index 3b6a7314a2..0000000000
--- a/spec/engines/sql/unit/primitives/expression_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Expression do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#to_sql' do
- it "manufactures sql with the expression and alias" do
- sql = Count.new(@attribute, :alias).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{COUNT(`users`.`id`) AS `alias`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{COUNT("USERS"."ID") AS "ALIAS"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{COUNT("users"."id") AS "alias"})
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/primitives/literal_spec.rb b/spec/engines/sql/unit/primitives/literal_spec.rb
deleted file mode 100644
index 3bf60100f1..0000000000
--- a/spec/engines/sql/unit/primitives/literal_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe SqlLiteral do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it "manufactures sql with a literal SQL fragment" do
- sql = @relation.project(Count.new(SqlLiteral.new("*"))).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM `users`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM "USERS"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{SELECT COUNT(*) AS count_id FROM "users"})
- end
- end
-
- it "manufactures expressions on literal SQL fragment" do
- sql = @relation.project(SqlLiteral.new("2 * credit_limit").sum).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{SELECT SUM(2 * credit_limit) AS sum_id FROM `users`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{SELECT SUM(2 * credit_limit) AS sum_id FROM "USERS"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{SELECT SUM(2 * credit_limit) AS sum_id FROM "users"})
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/primitives/value_spec.rb b/spec/engines/sql/unit/primitives/value_spec.rb
deleted file mode 100644
index 807090e31a..0000000000
--- a/spec/engines/sql/unit/primitives/value_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Value do
- 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')
-
- adapter_is_not :postgresql do
- Value.new('asdf', @relation).to_sql.should be_like("'asdf'")
- end
-
- adapter_is :postgresql do
- Value.new('asdf', @relation).to_sql.should be_like("E'asdf'")
- end
- end
- end
-
- describe '#format' do
- it "returns the sql of the provided object" do
- Value.new(1, @relation).format(@relation[:id]).should == @relation[:id].to_sql
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/alias_spec.rb b/spec/engines/sql/unit/relations/alias_spec.rb
deleted file mode 100644
index a6fd7ab036..0000000000
--- a/spec/engines/sql/unit/relations/alias_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Alias do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- describe 'when there is no ambiguity' do
- it 'does not alias table names anywhere a table name can appear' do
- sql = @relation \
- .where(@relation[:id].eq(1)) \
- .order(@relation[:id]) \
- .project(@relation[:id]) \
- .group(@relation[:id]) \
- .alias \
- .to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`
- FROM `users`
- WHERE `users`.`id` = 1
- GROUP BY `users`.`id`
- ORDER BY `users`.`id` ASC
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID"
- FROM "USERS"
- WHERE "USERS"."ID" = 1
- GROUP BY "USERS"."ID"
- ORDER BY "USERS"."ID" ASC
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id"
- FROM "users"
- WHERE "users"."id" = 1
- GROUP BY "users"."id"
- ORDER BY "users"."id" ASC
- })
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/delete_spec.rb b/spec/engines/sql/unit/relations/delete_spec.rb
deleted file mode 100644
index 302a13c688..0000000000
--- a/spec/engines/sql/unit/relations/delete_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Deletion do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it 'manufactures sql deleting a table relation' do
- sql = Deletion.new(@relation).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{DELETE FROM `users`})
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{DELETE FROM "USERS"})
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{DELETE FROM "users"})
- end
- end
-
- it 'manufactures sql deleting a where relation' do
- sql = Deletion.new(@relation.where(@relation[:id].eq(1))).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- DELETE
- FROM `users`
- WHERE `users`.`id` = 1
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- DELETE
- FROM "USERS"
- WHERE "USERS"."ID" = 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- DELETE
- FROM "users"
- WHERE "users"."id" = 1
- })
- end
- end
-
- it "manufactures sql deleting a ranged relation" do
- sql = Deletion.new(@relation.take(1)).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- DELETE
- FROM `users`
- LIMIT 1
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- DELETE
- FROM "USERS"
- WHERE ROWNUM <= 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- DELETE
- FROM "users"
- LIMIT 1
- })
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/from_spec.rb b/spec/engines/sql/unit/relations/from_spec.rb
deleted file mode 100644
index 0be3ac0f9a..0000000000
--- a/spec/engines/sql/unit/relations/from_spec.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Table do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it "manufactures a simple select query" do
- sql = @relation.from("workers").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM workers
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM workers
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM workers
- })
- end
- end
- end
-
- describe '#to_sql' do
- it "overrides and use last from clause given " do
- sql = @relation.from("workers").from("users").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM users
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM users
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM users
- })
- end
- end
- end
-
- end
-end
diff --git a/spec/engines/sql/unit/relations/group_spec.rb b/spec/engines/sql/unit/relations/group_spec.rb
deleted file mode 100644
index c32091bf08..0000000000
--- a/spec/engines/sql/unit/relations/group_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Group do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#to_sql' do
- describe 'when given a predicate' do
- it "manufactures sql with where clause conditions" do
- sql = Group.new(@relation, [@attribute]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- GROUP BY `users`.`id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- GROUP BY "USERS"."ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- GROUP BY "users"."id"
- })
- end
- end
- end
-
- describe 'when given a string' do
- it "passes the string through to the where clause" do
- sql = Group.new(@relation, ['asdf']).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- GROUP BY asdf
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- GROUP BY asdf
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- GROUP BY asdf
- })
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/having_spec.rb b/spec/engines/sql/unit/relations/having_spec.rb
deleted file mode 100644
index 931e8d0a06..0000000000
--- a/spec/engines/sql/unit/relations/having_spec.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Having do
- before do
- @relation = Table.new(:developers)
- end
-
- describe '#to_sql' do
- describe 'when given a predicate' do
- it "manufactures sql with where clause conditions" do
- sql = @relation.group(@relation[:department]).having("MIN(salary) > 1000").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `developers`.`id`, `developers`.`name`, `developers`.`salary`, `developers`.`department`, `developers`.`created_at`
- FROM `developers`
- GROUP BY `developers`.`department`
- HAVING MIN(salary) > 1000
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "DEVELOPERS"."ID", "DEVELOPERS"."NAME", "DEVELOPERS"."SALARY", "DEVELOPERS"."DEPARTMENT", "DEVELOPERS"."CREATED_AT"
- FROM "DEVELOPERS"
- GROUP BY "DEVELOPERS"."DEPARTMENT"
- HAVING MIN(salary) > 1000
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "developers"."id", "developers"."name", "developers"."salary", "developers"."department", "developers"."created_at"
- FROM "developers"
- GROUP BY "developers"."department"
- HAVING MIN(salary) > 1000
- })
- end
- end
- end
-
- describe 'when given two predicates' do
- it "manufactures sql with where clause conditions joined by AND" do
- sql = @relation.group(@relation[:department]).having("MIN(salary) > 1000", "MAX(salary) < 10000").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `developers`.`id`, `developers`.`name`, `developers`.`salary`, `developers`.`department`, `developers`.`created_at`
- FROM `developers`
- GROUP BY `developers`.`department`
- HAVING MIN(salary) > 1000 AND MAX(salary) < 10000
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "DEVELOPERS"."ID", "DEVELOPERS"."NAME", "DEVELOPERS"."SALARY", "DEVELOPERS"."DEPARTMENT", "DEVELOPERS"."CREATED_AT"
- FROM "DEVELOPERS"
- GROUP BY "DEVELOPERS"."DEPARTMENT"
- HAVING MIN(salary) > 1000 AND MAX(salary) < 10000
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "developers"."id", "developers"."name", "developers"."salary", "developers"."department", "developers"."created_at"
- FROM "developers"
- GROUP BY "developers"."department"
- HAVING MIN(salary) > 1000 AND MAX(salary) < 10000
- })
- end
- end
- end
- end
- end
-end
-
diff --git a/spec/engines/sql/unit/relations/insert_spec.rb b/spec/engines/sql/unit/relations/insert_spec.rb
deleted file mode 100644
index 4b412093e4..0000000000
--- a/spec/engines/sql/unit/relations/insert_spec.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Insert do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it 'manufactures sql inserting data when given multiple rows' do
- pending 'it should insert multiple rows' do
- @insertion = Insert.new(@relation, [@relation[:name] => "nick", @relation[:name] => "bryan"])
-
- @insertion.to_sql.should be_like("
- INSERT
- INTO `users`
- (`name`) VALUES ('nick'), ('bryan')
- ")
- end
- end
-
- it 'manufactures sql inserting data when given multiple values' do
- @insertion = Insert.new(@relation, @relation[:id] => "1", @relation[:name] => "nick")
-
- adapter_is :mysql do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO `users`
- (`id`, `name`) VALUES (1, 'nick')
- })
- end
-
- adapter_is :sqlite3 do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "users"
- ("id", "name") VALUES (1, 'nick')
- })
- end
-
- adapter_is :postgresql do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "users"
- ("id", "name") VALUES (1, E'nick')
- RETURNING "id"
- })
- end
-
- adapter_is :oracle do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "USERS"
- ("ID", "NAME") VALUES (1, 'nick')
- })
- end
- end
-
- describe 'when given values whose types correspond to the types of the attributes' do
- before do
- @insertion = Insert.new(@relation, @relation[:name] => "nick")
- end
-
- it 'manufactures sql inserting data' do
- adapter_is :mysql do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO `users`
- (`name`) VALUES ('nick')
- })
- end
-
- adapter_is :sqlite3 do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "users"
- ("name") VALUES ('nick')
- })
- end
-
- adapter_is :postgresql do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "users"
- ("name") VALUES (E'nick')
- RETURNING "id"
- })
- end
-
- adapter_is :oracle do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "USERS"
- ("NAME") VALUES ('nick')
- })
- end
- end
- end
-
- describe 'when given values whose types differ from from the types of the attributes' do
- before do
- @insertion = Insert.new(@relation, @relation[:id] => '1-asdf')
- end
-
- it 'manufactures sql inserting data' do
- adapter_is :mysql do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO `users`
- (`id`) VALUES (1)
- })
- end
-
- adapter_is :sqlite3 do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "users"
- ("id") VALUES (1)
- })
- end
-
- adapter_is :postgresql do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "users"
- ("id") VALUES (1)
- RETURNING "id"
- })
- end
-
- adapter_is :oracle do
- @insertion.to_sql.should be_like(%Q{
- INSERT
- INTO "USERS"
- ("ID") VALUES (1)
- })
- end
-
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/join_spec.rb b/spec/engines/sql/unit/relations/join_spec.rb
deleted file mode 100644
index cbbcb18244..0000000000
--- a/spec/engines/sql/unit/relations/join_spec.rb
+++ /dev/null
@@ -1,180 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Join do
- before do
- @relation1 = Table.new(:users)
- @relation2 = Table.new(:photos)
- @predicate1 = @relation1[:id].eq(@relation2[:user_id])
-
- @relation3 = Table.new(:users, :as => :super_users)
- @relation4 = Table.new(:photos, :as => :super_photos)
-
- @predicate2 = @relation3[:id].eq(@relation2[:user_id])
- @predicate3 = @relation3[:id].eq(@relation4[:user_id])
- end
-
- describe '#to_sql' do
-
- describe 'when joining with another relation' do
- it 'manufactures sql joining the two tables on the predicate' do
- sql = InnerJoin.new(@relation1, @relation2, @predicate1).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
- FROM `users`
- INNER JOIN `photos` ON `users`.`id` = `photos`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
- FROM "USERS"
- INNER JOIN "PHOTOS" ON "USERS"."ID" = "PHOTOS"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
- FROM "users"
- INNER JOIN "photos" ON "users"."id" = "photos"."user_id"
- })
- end
- end
-
- describe 'when joining with another relation with an aliased table' do
- it 'manufactures sql joining the two tables on the predicate respecting table aliasing' do
- sql = InnerJoin.new(@relation3, @relation2, @predicate2).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `super_users`.`id`, `super_users`.`name`, `photos`.`id`, `photos`.`user_id`, `photos`.`camera_id`
- FROM `users` `super_users`
- INNER JOIN `photos` ON `super_users`.`id` = `photos`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "SUPER_USERS"."ID", "SUPER_USERS"."NAME", "PHOTOS"."ID", "PHOTOS"."USER_ID", "PHOTOS"."CAMERA_ID"
- FROM "USERS" "SUPER_USERS"
- INNER JOIN "PHOTOS" ON "SUPER_USERS"."ID" = "PHOTOS"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "super_users"."id", "super_users"."name", "photos"."id", "photos"."user_id", "photos"."camera_id"
- FROM "users" "super_users"
- INNER JOIN "photos" ON "super_users"."id" = "photos"."user_id"
- })
- end
- end
- end
-
- describe 'when joining with two relations with aliased tables' do
- it 'manufactures sql joining the two tables on the predicate respecting table aliasing' do
- sql = InnerJoin.new(@relation3, @relation4, @predicate3).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `super_users`.`id`, `super_users`.`name`, `super_photos`.`id`, `super_photos`.`user_id`, `super_photos`.`camera_id`
- FROM `users` `super_users`
- INNER JOIN `photos` `super_photos` ON `super_users`.`id` = `super_photos`.`user_id`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "SUPER_USERS"."ID", "SUPER_USERS"."NAME", "SUPER_PHOTOS"."ID", "SUPER_PHOTOS"."USER_ID", "SUPER_PHOTOS"."CAMERA_ID"
- FROM "USERS" "SUPER_USERS"
- INNER JOIN "PHOTOS" "SUPER_PHOTOS" ON "SUPER_USERS"."ID" = "SUPER_PHOTOS"."USER_ID"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "super_users"."id", "super_users"."name", "super_photos"."id", "super_photos"."user_id", "super_photos"."camera_id"
- FROM "users" "super_users"
- INNER JOIN "photos" "super_photos" ON "super_users"."id" = "super_photos"."user_id"
- })
- end
- end
- end
-
- end
-
- describe 'when joining with a string' do
- it "passes the string through to the where clause" do
- sql = StringJoin.new(@relation1, "INNER JOIN asdf ON fdsa").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- INNER JOIN asdf ON fdsa
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- INNER JOIN asdf ON fdsa
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- INNER JOIN asdf ON fdsa
- })
- end
- end
-
- it "passes the string when there are multiple string joins" do
- relation = StringJoin.new(@relation1, "INNER JOIN asdf ON fdsa")
- relation = StringJoin.new(relation, "INNER JOIN lifo ON fifo")
- sql = StringJoin.new(relation, "INNER JOIN hatful ON hallow").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- INNER JOIN asdf ON fdsa
- INNER JOIN lifo ON fifo
- INNER JOIN hatful ON hallow
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- INNER JOIN asdf ON fdsa
- INNER JOIN lifo ON fifo
- INNER JOIN hatful ON hallow
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- INNER JOIN asdf ON fdsa
- INNER JOIN lifo ON fifo
- INNER JOIN hatful ON hallow
- })
- end
- end
-
- end
-
-
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/lock_spec.rb b/spec/engines/sql/unit/relations/lock_spec.rb
deleted file mode 100644
index 72a8a2e457..0000000000
--- a/spec/engines/sql/unit/relations/lock_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Lock do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it "manufactures a simple select query lock" do
- sql = @relation.lock.to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users` FOR UPDATE
- })
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users" FOR UPDATE
- })
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS" FOR UPDATE
- })
-
- sql_with_order_by = @relation.order(@relation[:id]).take(1).lock.to_sql
- sql_with_order_by.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- WHERE "ID" IN (select * from
- (SELECT "ID" FROM "USERS" ORDER BY "USERS"."ID" ASC)
- where rownum <= 1)
- FOR UPDATE
- })
-
- end
- end
-
- it "manufactures a select query locking with a given lock" do
- sql = @relation.lock("LOCK IN SHARE MODE").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users` LOCK IN SHARE MODE
- })
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users" LOCK IN SHARE MODE
- })
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS" LOCK IN SHARE MODE
- })
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/order_spec.rb b/spec/engines/sql/unit/relations/order_spec.rb
deleted file mode 100644
index 59637876bf..0000000000
--- a/spec/engines/sql/unit/relations/order_spec.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Order do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#to_sql' do
- describe "when given an attribute" do
- it "manufactures sql with an order clause populated by the attribute" do
- sql = Order.new(@relation, [@attribute]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- ORDER BY `users`.`id` ASC
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- ORDER BY "USERS"."ID" ASC
- })
-
- distinct_attributes = ActiveRecord::Base.connection.distinct('"USERS"."NAME"', '"USERS"."ID"')
- @relation.project(distinct_attributes).order(@relation[:id]).to_sql.should be_like(%Q{
- SELECT DISTINCT "USERS"."NAME",
- FIRST_VALUE("USERS"."ID") OVER (PARTITION BY "USERS"."NAME" ORDER BY "USERS"."ID") AS alias_0__
- FROM "USERS"
- ORDER BY alias_0__
- })
-
- distinct_attributes = ActiveRecord::Base.connection.distinct('"USERS"."NAME"', '"USERS"."ID" DESC')
- @relation.project(distinct_attributes).order('"USERS"."ID" DESC').to_sql.should be_like(%Q{
- SELECT DISTINCT "USERS"."NAME",
- FIRST_VALUE("USERS"."ID") OVER (PARTITION BY "USERS"."NAME" ORDER BY "USERS"."ID" DESC) AS alias_0__
- FROM "USERS"
- ORDER BY alias_0__ DESC
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- ORDER BY "users"."id" ASC
- })
- end
- end
- end
-
- describe "when given multiple attributes" do
- before do
- @another_attribute = @relation[:name]
- end
-
- it "manufactures sql with an order clause populated by comma-separated attributes" do
- sql = Order.new(@relation, [@attribute, @another_attribute]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- ORDER BY `users`.`id` ASC, `users`.`name` ASC
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- ORDER BY "USERS"."ID" ASC, "USERS"."NAME" ASC
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- ORDER BY "users"."id" ASC, "users"."name" ASC
- })
- end
- end
- end
-
- describe "when given a string" do
- before do
- @string = "asdf"
- end
-
- it "passes the string through to the order clause" do
- sql = Order.new(@relation, [@string]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- ORDER BY asdf
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- ORDER BY asdf
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- ORDER BY asdf
- })
- end
- end
- end
-
- describe "when ordering an ordered relation" do
- before do
- @ordered_relation = Order.new(@relation, [@attribute])
- @another_attribute = @relation[:name]
- end
-
- it "manufactures sql with the order clause of the last ordering preceding the first ordering" do
- sql = Order.new(@ordered_relation, [@another_attribute]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- ORDER BY `users`.`name` ASC, `users`.`id` ASC
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- ORDER BY "USERS"."NAME" ASC, "USERS"."ID" ASC
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- ORDER BY "users"."name" ASC, "users"."id" ASC
- })
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/project_spec.rb b/spec/engines/sql/unit/relations/project_spec.rb
deleted file mode 100644
index b5d2d33d4b..0000000000
--- a/spec/engines/sql/unit/relations/project_spec.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Project do
- before do
- @relation = Table.new(:users)
- @attribute = @relation[:id]
- end
-
- describe '#to_sql' do
- describe 'when given an attribute' do
- it "manufactures sql with a limited select clause" do
- sql = Project.new(@relation, [@attribute]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`
- FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID"
- FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id"
- FROM "users"
- })
- end
- end
- end
-
- describe 'when given a relation' do
- before do
- @scalar_relation = Project.new(@relation, [@relation[:name]])
- end
-
- it "manufactures sql with scalar selects" do
- sql = Project.new(@relation, [@scalar_relation]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT (SELECT `users`.`name` FROM `users`) AS `users` FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT (SELECT "USERS"."NAME" FROM "USERS") AS "USERS" FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT (SELECT "users"."name" FROM "users") AS "users" FROM "users"
- })
- end
- end
- end
-
- describe 'when given a string' do
- it "passes the string through to the select clause" do
- sql = Project.new(@relation, ['asdf']).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT asdf FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT asdf FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT asdf FROM "users"
- })
- end
- end
- end
-
- describe 'when given an expression' do
- it 'manufactures sql with expressions' do
- sql = @relation.project(@attribute.count).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT COUNT(`users`.`id`) AS count_id
- FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT COUNT("USERS"."ID") AS count_id
- FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT COUNT("users"."id") AS count_id
- FROM "users"
- })
- end
- end
-
- it 'manufactures sql with distinct expressions' do
- sql = @relation.project(@attribute.count(true)).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT COUNT(DISTINCT `users`.`id`) AS count_id
- FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT COUNT(DISTINCT "USERS"."ID") AS count_id
- FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT COUNT(DISTINCT "users"."id") AS count_id
- FROM "users"
- })
- end
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/skip_spec.rb b/spec/engines/sql/unit/relations/skip_spec.rb
deleted file mode 100644
index 41b80d12d8..0000000000
--- a/spec/engines/sql/unit/relations/skip_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Skip do
- before do
- @relation = Table.new(:users)
- @skipped = 4
- end
-
- describe '#to_sql' do
- it "manufactures sql with limit and offset" do
- sql = Skip.new(@relation, @skipped).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- OFFSET 4
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- select * from (select raw_sql_.*, rownum raw_rnum_ from
- (SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS") raw_sql_)
- where raw_rnum_ > 4
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- OFFSET 4
- })
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/table_spec.rb b/spec/engines/sql/unit/relations/table_spec.rb
deleted file mode 100644
index 1a0914006b..0000000000
--- a/spec/engines/sql/unit/relations/table_spec.rb
+++ /dev/null
@@ -1,122 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Table do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it "manufactures a simple select query" do
- sql = @relation.to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- })
- end
- end
- end
-
- describe '#as' do
- it "manufactures a simple select query using aliases" do
- sql = @relation.as(:super_users).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `super_users`.`id`, `super_users`.`name`
- FROM `users` `super_users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "SUPER_USERS"."ID", "SUPER_USERS"."NAME"
- FROM "USERS" "SUPER_USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "super_users"."id", "super_users"."name"
- FROM "users" "super_users"
- })
- end
- end
-
- it "does not apply alias if it's same as the table name" do
- sql = @relation.as(:users).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- })
- end
- end
-
- end
-
- describe '#column_for' do
- it "returns the column corresponding to the attribute" do
- @relation.column_for(@relation[:id]).should == @relation.columns.detect { |c| c.name == 'id' }
- end
- end
-
- describe '#attributes' do
- it 'manufactures attributes corresponding to columns in the table' do
- @relation.attributes.should == [
- Attribute.new(@relation, :id),
- Attribute.new(@relation, :name)
- ]
- end
-
- describe '#reset' do
- it "reloads columns from the database" do
- lambda { @relation.engine.stub!(:columns => []) }.should_not change { @relation.attributes }
- lambda { @relation.reset }.should change { @relation.attributes }
- end
- end
- end
-
- describe '#engine' do
- it "defaults to global engine" do
- Table.engine = engine = Sql::Engine.new
- Table.new(:users).engine.should == engine
- end
-
- it "can be specified" do
- Table.new(:users, engine = Sql::Engine.new).engine.should == engine
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/take_spec.rb b/spec/engines/sql/unit/relations/take_spec.rb
deleted file mode 100644
index ad46190f7e..0000000000
--- a/spec/engines/sql/unit/relations/take_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Take do
- before do
- @relation = Table.new(:users)
- @taken = 4
- end
-
- describe '#to_sql' do
- it "manufactures sql with limit and offset" do
- sql = Take.new(@relation, @taken).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- LIMIT 4
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- WHERE ROWNUM <= 4
- })
-
- sql_with_order_by = Take.new(@relation.order(@relation[:id]), @taken).to_sql
- sql_with_order_by.should be_like(%Q{
- select * from
- (SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- ORDER BY "USERS"."ID" ASC)
- where rownum <= 4
- })
-
- sql_with_distinct = Take.new(@relation.project('DISTINCT "USERS"."ID"'), @taken).to_sql
- sql_with_distinct.should be_like(%Q{
- select * from
- (SELECT DISTINCT "USERS"."ID"
- FROM "USERS")
- where rownum <= 4
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- LIMIT 4
- })
- end
- end
-
- it "manufactures count sql with limit" do
- sql = Take.new(@relation.project(@relation[:id].count), @taken).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT COUNT(*) AS count_id
- FROM (SELECT 1 FROM `users` LIMIT 4) AS subquery
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT COUNT(*) AS count_id
- FROM (SELECT 1 FROM "users" LIMIT 4) AS subquery
- })
- end
- end
- end
- end
-end
diff --git a/spec/engines/sql/unit/relations/update_spec.rb b/spec/engines/sql/unit/relations/update_spec.rb
deleted file mode 100644
index cc2ad9913b..0000000000
--- a/spec/engines/sql/unit/relations/update_spec.rb
+++ /dev/null
@@ -1,203 +0,0 @@
-require 'spec_helper'
-
-class User
- def self.primary_key
- "id"
- end
-end
-
-module Arel
- describe Update do
- before do
- @relation = Table.new(:users)
- end
-
- describe '#to_sql' do
- it "manufactures sql updating attributes when given multiple attributes" do
- sql = Update.new(@relation, @relation[:id] => 1, @relation[:name] => "nick").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- UPDATE `users`
- SET `id` = 1, `name` = 'nick'
- })
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{
- UPDATE "users"
- SET "id" = 1, "name" = 'nick'
- })
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{
- UPDATE "users"
- SET "id" = 1, "name" = E'nick'
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- UPDATE "USERS"
- SET "ID" = 1, "NAME" = 'nick'
- })
- end
- end
-
- it "manufactures sql updating attributes when given a ranged relation" do
- sql = Update.new(@relation.take(1), @relation[:name] => "nick").to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- UPDATE `users`
- SET `name` = 'nick'
- LIMIT 1
- })
- end
-
- adapter_is :sqlite3 do
- sql.should be_like(%Q{
- UPDATE "users" SET
- "name" = 'nick'
- WHERE "id" IN (SELECT "id" FROM "users" LIMIT 1)
- })
- end
-
- adapter_is :postgresql do
- sql.should be_like(%Q{
- UPDATE "users" SET
- "name" = E'nick'
- WHERE "id" IN (SELECT "id" FROM "users" LIMIT 1)
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- UPDATE "USERS" SET
- "NAME" = 'nick'
- WHERE "ID" IN (SELECT "ID" FROM "USERS" WHERE ROWNUM <= 1)
- })
-
- sql_with_order_by = Update.new(@relation.order(@relation[:id]).take(1), @relation[:name] => "nick").to_sql
- sql_with_order_by.should be_like(%Q{
- UPDATE "USERS" SET
- "NAME" = 'nick'
- WHERE "ID" IN (select * from
- (SELECT "ID" FROM "USERS" ORDER BY "USERS"."ID" ASC)
- where rownum <= 1)
- })
- end
- end
-
- describe 'when given values whose types correspond to the types of the attributes' do
- before do
- @update = Update.new(@relation, @relation[:name] => "nick")
- end
-
- it 'manufactures sql updating attributes' do
- adapter_is :mysql do
- @update.to_sql.should be_like(%Q{
- UPDATE `users`
- SET `name` = 'nick'
- })
- end
-
- adapter_is :sqlite3 do
- @update.to_sql.should be_like(%Q{
- UPDATE "users"
- SET "name" = 'nick'
- })
- end
-
- adapter_is :postgresql do
- @update.to_sql.should be_like(%Q{
- UPDATE "users"
- SET "name" = E'nick'
- })
- end
-
- adapter_is :oracle do
- @update.to_sql.should be_like(%Q{
- UPDATE "USERS"
- SET "NAME" = 'nick'
- })
- end
- end
- end
-
- describe 'when given values whose types differ from from the types of the attributes' do
- before do
- @update = Update.new(@relation, @relation[:id] => '1-asdf')
- end
-
- it 'manufactures sql updating attributes' do
- adapter_is :mysql do
- @update.to_sql.should be_like(%Q{
- UPDATE `users`
- SET `id` = 1
- })
- end
-
- adapter_is :oracle do
- @update.to_sql.should be_like(%Q{
- UPDATE "USERS"
- SET "ID" = 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- @update.to_sql.should be_like(%Q{
- UPDATE "users"
- SET "id" = 1
- })
- end
- end
- end
-
- describe 'when the relation is a where' do
- before do
- @update = Update.new(
- @relation.where(@relation[:id].eq(1)),
- @relation[:name] => "nick"
- )
- end
-
- it 'manufactures sql updating a where relation' do
- adapter_is :mysql do
- @update.to_sql.should be_like(%Q{
- UPDATE `users`
- SET `name` = 'nick'
- WHERE `users`.`id` = 1
- })
- end
-
- adapter_is :sqlite3 do
- @update.to_sql.should be_like(%Q{
- UPDATE "users"
- SET "name" = 'nick'
- WHERE "users"."id" = 1
- })
- end
-
- adapter_is :postgresql do
- @update.to_sql.should be_like(%Q{
- UPDATE "users"
- SET "name" = E'nick'
- WHERE "users"."id" = 1
- })
- end
-
- adapter_is :oracle do
- @update.to_sql.should be_like(%Q{
- UPDATE "USERS"
- SET "NAME" = 'nick'
- WHERE "USERS"."ID" = 1
- })
- end
- end
- end
- end
-
- end
-end
diff --git a/spec/engines/sql/unit/relations/where_spec.rb b/spec/engines/sql/unit/relations/where_spec.rb
deleted file mode 100644
index 69793d63a1..0000000000
--- a/spec/engines/sql/unit/relations/where_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-require 'spec_helper'
-
-module Arel
- describe Where do
- before do
- @relation = Table.new(:users)
- @predicate = @relation[:id].eq(1)
- end
-
- describe '#to_sql' do
- describe 'when given a predicate' do
- it "manufactures sql with where clause conditions" do
- sql = Where.new(@relation, [@predicate]).to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- WHERE `users`.`id` = 1
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- WHERE "USERS"."ID" = 1
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- WHERE "users"."id" = 1
- })
- end
- end
- end
-
- describe 'when given a string' do
- it "passes the string through to the where clause" do
- sql = Where.new(@relation, 'asdf').to_sql
-
- adapter_is :mysql do
- sql.should be_like(%Q{
- SELECT `users`.`id`, `users`.`name`
- FROM `users`
- WHERE asdf
- })
- end
-
- adapter_is :oracle do
- sql.should be_like(%Q{
- SELECT "USERS"."ID", "USERS"."NAME"
- FROM "USERS"
- WHERE asdf
- })
- end
-
- adapter_is_not :mysql, :oracle do
- sql.should be_like(%Q{
- SELECT "users"."id", "users"."name"
- FROM "users"
- WHERE asdf
- })
- end
- end
- end
- end
- end
-end
diff --git a/spec/arel/insert_manager_spec.rb b/spec/insert_manager_spec.rb
index 1cd61ae630..1cd61ae630 100644
--- a/spec/arel/insert_manager_spec.rb
+++ b/spec/insert_manager_spec.rb
diff --git a/spec/arel/nodes/count_spec.rb b/spec/nodes/count_spec.rb
index 185b4d8eb9..185b4d8eb9 100644
--- a/spec/arel/nodes/count_spec.rb
+++ b/spec/nodes/count_spec.rb
diff --git a/spec/arel/nodes/delete_statement_spec.rb b/spec/nodes/delete_statement_spec.rb
index 4d12d184fb..4d12d184fb 100644
--- a/spec/arel/nodes/delete_statement_spec.rb
+++ b/spec/nodes/delete_statement_spec.rb
diff --git a/spec/arel/nodes/equality_spec.rb b/spec/nodes/equality_spec.rb
index 81eea4d482..81eea4d482 100644
--- a/spec/arel/nodes/equality_spec.rb
+++ b/spec/nodes/equality_spec.rb
diff --git a/spec/arel/nodes/insert_statement_spec.rb b/spec/nodes/insert_statement_spec.rb
index 0e2432c021..0e2432c021 100644
--- a/spec/arel/nodes/insert_statement_spec.rb
+++ b/spec/nodes/insert_statement_spec.rb
diff --git a/spec/arel/nodes/or_spec.rb b/spec/nodes/or_spec.rb
index 88484ff4f7..88484ff4f7 100644
--- a/spec/arel/nodes/or_spec.rb
+++ b/spec/nodes/or_spec.rb
diff --git a/spec/arel/nodes/select_core_spec.rb b/spec/nodes/select_core_spec.rb
index d2e87c2c23..d2e87c2c23 100644
--- a/spec/arel/nodes/select_core_spec.rb
+++ b/spec/nodes/select_core_spec.rb
diff --git a/spec/arel/nodes/select_statement_spec.rb b/spec/nodes/select_statement_spec.rb
index 68bde3c4f7..68bde3c4f7 100644
--- a/spec/arel/nodes/select_statement_spec.rb
+++ b/spec/nodes/select_statement_spec.rb
diff --git a/spec/arel/nodes/sql_literal_spec.rb b/spec/nodes/sql_literal_spec.rb
index 390eb708e1..390eb708e1 100644
--- a/spec/arel/nodes/sql_literal_spec.rb
+++ b/spec/nodes/sql_literal_spec.rb
diff --git a/spec/arel/nodes/sum_spec.rb b/spec/nodes/sum_spec.rb
index 7691b06590..7691b06590 100644
--- a/spec/arel/nodes/sum_spec.rb
+++ b/spec/nodes/sum_spec.rb
diff --git a/spec/arel/nodes/update_statement_spec.rb b/spec/nodes/update_statement_spec.rb
index 860d1c448a..860d1c448a 100644
--- a/spec/arel/nodes/update_statement_spec.rb
+++ b/spec/nodes/update_statement_spec.rb
diff --git a/spec/relations/join_spec.rb b/spec/relations/join_spec.rb
deleted file mode 100644
index b4a46fae97..0000000000
--- a/spec/relations/join_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'spec_helper'
-
-describe "Arel" do
- before :all do
- @owner = Arel::Model.build do |r|
- r.engine Arel::Testing::Engine.new
-
- r.attribute :id, Arel::Attributes::Integer
- end
-
- @thing = Arel::Model.build do |r|
- r.engine Arel::Testing::Engine.new
-
- r.attribute :id, Arel::Attributes::Integer
- r.attribute :owner_id, Arel::Attributes::Integer
- r.attribute :name, Arel::Attributes::String
- r.attribute :age, Arel::Attributes::Integer
- end
- end
-
- describe "Join" do
- before :all do
- @relation = @thing.join(@owner).on(@thing[:owner_id].eq(@owner[:id]))
- @expected = []
-
- 3.times do |owner_id|
- @owner.insert([owner_id])
-
- 8.times do |i|
- thing_id = owner_id * 8 + i
- age = 2 * thing_id
- name = "Name #{thing_id % 6}"
-
- @thing.insert([thing_id, owner_id, name, age])
- @expected << Arel::Row.new(@relation, [thing_id, owner_id, name, age, owner_id])
- end
- end
- end
-
- it_should_behave_like 'A Relation'
- end
-end
diff --git a/spec/relations/relation_spec.rb b/spec/relations/relation_spec.rb
deleted file mode 100644
index cfc1c1410b..0000000000
--- a/spec/relations/relation_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'spec_helper'
-
-describe "Arel" do
- before :all do
- @engine = Arel::Testing::Engine.new
- @relation = Arel::Model.build do |r|
- r.engine @engine
-
- r.attribute :id, Arel::Attributes::Integer
- r.attribute :name, Arel::Attributes::String
- r.attribute :age, Arel::Attributes::Integer
- end
- end
-
- describe "Relation" do
- before :all do
- @expected = (1..20).map { |i| @relation.insert([i, "Name #{i % 6}", 2 * i]) }
- end
-
- it_should_behave_like 'A Relation'
- end
-
- describe "Relation" do
- describe "#insert" do
- it "inserts the row into the engine" do
- @relation.insert([1, 'Foo', 10])
- @engine.rows.should == [[1, 'Foo', 10]]
- end
- end
- end
-end
diff --git a/spec/arel/select_manager_spec.rb b/spec/select_manager_spec.rb
index 7002d937a2..7002d937a2 100644
--- a/spec/arel/select_manager_spec.rb
+++ b/spec/select_manager_spec.rb
diff --git a/spec/shared/relation_spec.rb b/spec/shared/relation_spec.rb
deleted file mode 100644
index a5a22edb7d..0000000000
--- a/spec/shared/relation_spec.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-share_examples_for 'A Relation' do
-
- before :all do
- # The two needed instance variables need to be set in a
- # before :all callback.
- # @relation is the relation being tested here.
- # @expected is an array of the elements that are expected to be in
- # the relation.
- %w[ @relation @expected ].each do |ivar|
- raise "#{ivar} needs to be defined" unless instance_variable_get(ivar)
- end
-
- # There needs to be enough items to be able to run all the tests
- raise "@expected needs to have at least 6 items" unless @expected.length >= 6
- end
-
- before :each do
- @expected = @expected.dup
- end
-
- describe "#each" do
- it "iterates over the rows in any order" do
- @relation.should have_rows(@expected)
- end
- end
-
- describe "#where" do
- before :all do
- @expected = @expected.sort_by { |r| r[@relation[:age]] }
- @pivot = @expected[@expected.length / 2]
- end
-
- it "finds rows with an equal to predicate" do
- expected = @expected.select { |r| r[@relation[:age]] == @pivot[@relation[:age]] }
- @relation.where(@relation[:age].eq(@pivot[@relation[:age]])).should have_rows(expected)
- end
-
- it "finds rows with an equal to complement predicate" do
- expected = @expected.select { |r| r[@relation[:age]] != @pivot[@relation[:age]] }
- @relation.where(@relation[:age].eq(@pivot[@relation[:age]]).complement).should have_rows(expected)
- end
-
- it "finds rows with a not eq predicate" do
- expected = @expected.select { |r| r[@relation[:age]] != @pivot[@relation[:age]] }
- @relation.where(@relation[:age].not_eq(@pivot[@relation[:age]])).should have_rows(expected)
- end
-
- it "finds rows with an not eq complement predicate" do
- expected = @expected.select { |r| r[@relation[:age]] == @pivot[@relation[:age]] }
- @relation.where(@relation[:age].not_eq(@pivot[@relation[:age]]).complement).should have_rows(expected)
- end
-
- it "finds rows with a less than predicate" do
- expected = @expected.select { |r| r[@relation[:age]] < @pivot[@relation[:age]] }
- @relation.where(@relation[:age].lt(@pivot[@relation[:age]])).should have_rows(expected)
- end
-
- it "finds rows with a less than complement predicate" do
- expected = @expected.select { |r| r[@relation[:age]] >= @pivot[@relation[:age]] }
- @relation.where(@relation[:age].lt(@pivot[@relation[:age]]).complement).should have_rows(expected)
- end
-
- it "finds rows with a less than or equal to predicate" do
- expected = @expected.select { |r| r[@relation[:age]] <= @pivot[@relation[:age]] }
- @relation.where(@relation[:age].lteq(@pivot[@relation[:age]])).should have_rows(expected)
- end
-
- it "finds rows with a less than or equal to complement predicate" do
- expected = @expected.select { |r| r[@relation[:age]] > @pivot[@relation[:age]] }
- @relation.where(@relation[:age].lteq(@pivot[@relation[:age]]).complement).should have_rows(expected)
- end
-
- it "finds rows with a greater than predicate" do
- expected = @expected.select { |r| r[@relation[:age]] > @pivot[@relation[:age]] }
- @relation.where(@relation[:age].gt(@pivot[@relation[:age]])).should have_rows(expected)
- end
-
- it "finds rows with a greater than complement predicate" do
- expected = @expected.select { |r| r[@relation[:age]] <= @pivot[@relation[:age]] }
- @relation.where(@relation[:age].gt(@pivot[@relation[:age]]).complement).should have_rows(expected)
- end
-
- it "finds rows with a greater than or equal to predicate" do
- expected = @expected.select { |r| r[@relation[:age]] >= @pivot[@relation[:age]] }
- @relation.where(@relation[:age].gteq(@pivot[@relation[:age]])).should have_rows(expected)
- end
-
- it "finds rows with a greater than or equal to complement predicate" do
- expected = @expected.select { |r| r[@relation[:age]] < @pivot[@relation[:age]] }
- @relation.where(@relation[:age].gteq(@pivot[@relation[:age]]).complement).should have_rows(expected)
- end
-
- it "finds rows with a matches predicate" do
- expected = @expected.select { |r| r[@relation[:name]] =~ /#{@pivot[@relation[:name]]}/ }
- @relation.where(@relation[:name].matches(/#{@pivot[@relation[:name]]}/)).should have_rows(expected)
- end
-
- it "finds rows with a matches complement predicate" do
- expected = @expected.select { |r| r[@relation[:name]] !~ /#{@pivot[@relation[:name]]}/ }
- @relation.where(@relation[:name].matches(/#{@pivot[@relation[:name]]}/).complement).should have_rows(expected)
- end
-
- it "finds rows with a not matches predicate" do
- expected = @expected.select { |r| r[@relation[:name]] !~ /#{@pivot[@relation[:name]]}/ }
- @relation.where(@relation[:name].not_matches(/#{@pivot[@relation[:name]]}/)).should have_rows(expected)
- end
-
- it "finds rows with a not matches complement predicate" do
- expected = @expected.select { |r| r[@relation[:name]] =~ /#{@pivot[@relation[:name]]}/ }
- @relation.where(@relation[:name].not_matches(/#{@pivot[@relation[:name]]}/).complement).should have_rows(expected)
- end
-
- it "finds rows with an in predicate" do
- expected = @expected.select {|r| r[@relation[:age]] >=3 && r[@relation[:age]] <= 20}
- @relation.where(@relation[:age].in(3..20)).should have_rows(expected)
- end
-
- it "finds rows with an in complement predicate" do
- expected = @expected.select {|r| !(r[@relation[:age]] >=3 && r[@relation[:age]] <= 20)}
- @relation.where(@relation[:age].in(3..20).complement).should have_rows(expected)
- end
-
- it "finds rows with a not in predicate" do
- expected = @expected.select {|r| !(r[@relation[:age]] >=3 && r[@relation[:age]] <= 20)}
- @relation.where(@relation[:age].not_in(3..20)).should have_rows(expected)
- end
-
- it "finds rows with a not in complement predicate" do
- expected = @expected.select {|r| r[@relation[:age]] >=3 && r[@relation[:age]] <= 20}
- @relation.where(@relation[:age].not_in(3..20).complement).should have_rows(expected)
- end
-
- it "finds rows with a polyadic predicate of class Any" do
- expected = @expected.select {|r| [2,4,8,16].include?(r[@relation[:age]])}
- @relation.where(@relation[:age].in_any([2,4], [8, 16])).should have_rows(expected)
- end
-
- it "finds rows with a polyadic predicate of class Any complement" do
- expected = @expected.select {|r| ![2,4,8,16].include?(r[@relation[:age]])}
- @relation.where(@relation[:age].in_any([2,4], [8, 16]).complement).should have_rows(expected)
- end
-
- it "finds rows with a polyadic predicate of class All" do
- expected = @expected.select {|r| r[@relation[:name]] =~ /Name/ && r[@relation[:name]] =~ /1/}
- @relation.where(@relation[:name].matches_all(/Name/, /1/)).should have_rows(expected)
- end
-
- it "finds rows with a polyadic predicate of class All complement" do
- expected = @expected.select {|r| !(r[@relation[:name]] =~ /Name/ && r[@relation[:name]] =~ /1/)}
- @relation.where(@relation[:name].matches_all(/Name/, /1/).complement).should have_rows(expected)
- end
- end
-
- describe "#order" do
- describe "by one attribute" do
- before :all do
- @expected.sort! { |a, b| a[@relation[:age]] <=> b[@relation[:age]]}.map! {|e| e[@relation[:id]]}
- end
-
- it "can be specified as ascending order" do
- actual = []
- @relation.order(@relation[:age].asc).each { |r| actual << r[@relation[:id]] }
- actual.should == @expected
- end
-
- it "can be specified as descending order" do
- actual = []
- @relation.order(@relation[:age].desc).each { |r| actual << r[@relation[:id]] }
- actual.should == @expected.reverse
- end
- end
-
- describe "by two attributes in two separate calls to #order" do
- before :all do
- @expected = @expected.sort_by { |e| [e[@relation[:name]], e[@relation[:age]]]}.map {|e| e[@relation[:id]]}
- end
-
- it "can be specified as ascending order" do
- actual = []
- @relation.order(@relation[:age].asc).order(@relation[:name].asc).each { |r| actual << r[@relation[:id]] }
- actual.should == @expected
- end
-
- it "can be specified as descending order" do
- actual = []
- @relation.order(@relation[:age].desc).order(@relation[:name].desc).each { |r| actual << r[@relation[:id]] }
- actual.should == @expected.reverse
- end
- end
-
- describe "by two attributes in one call to #order" do
- before :all do
- @expected = @expected.sort_by { |e| [e[@relation[:name]], e[@relation[:age]]]}.map {|e| e[@relation[:id]]}
- end
-
- it "can be specified as ascending order in one call to #order" do
- actual = []
- @relation.order(@relation[:name].asc, @relation[:age].asc).each { |r| actual << r[@relation[:id]] }
- actual.should == @expected
- end
-
- it "can be specified as descending order in one call to #order" do
- actual = []
- @relation.order(@relation[:name].desc, @relation[:age].desc).each { |r| actual << r[@relation[:id]] }
- actual.should == @expected.reverse
- end
- end
- end
-
- describe "#take" do
- it "returns a relation" do
- @relation.take(3).should be_a(Arel::Relation)
- end
-
- it "returns X items from the collection" do
- length = @expected.length
-
- @relation.take(3).each do |resource|
- @expected.delete_if { |r| r.tuple == resource.tuple }
- end
-
- @expected.length.should == length - 3
- end
-
- it "works with ordering" do
- expected = @expected.sort_by { |r| [r[@relation[:age]], r[@relation[:id]]] }.map { |r| r[@relation[:id]] }
- actual = @relation.order(@relation[:age].asc, @relation[:id].asc).take(3).map { |r| r[@relation[:id]] }
-
- actual.should == expected[0,3]
- end
- end
-
- describe "#skip" do
- it "returns a relation" do
- @relation.skip(3).should be_a(Arel::Relation)
- end
-
- it "skips X items from the collection" do
- length = @expected.length
-
- @relation.skip(3).each do |resource|
- @expected.delete_if { |r| r.tuple == resource.tuple }
- end
-
- @expected.length.should == 3
- end
-
- it "works with ordering" do
- expected = @expected.sort_by { |r| [r[@relation[:age]], r[@relation[:id]]] }.map { |r| r[@relation[:id]] }
- actual = @relation.order(@relation[:age].asc, @relation[:id].asc).skip(3).map { |r| r[@relation[:id]] }
-
- actual.should == expected[3..-1]
- end
- end
-end
diff --git a/spec/sql/christener_spec.rb b/spec/sql/christener_spec.rb
deleted file mode 100644
index 895ec2a9b6..0000000000
--- a/spec/sql/christener_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require 'spec_helper'
-
-module Arel
- module Sql
- describe "Christener" do
- it "returns the first name" do
- christener = Christener.new
- table = Table.new 'users'
- table2 = Table.new 'pictures'
- christener.name_for(table).should == 'users'
- christener.name_for(table2).should == 'pictures'
- christener.name_for(table).should == 'users'
- end
-
- it "returns a unique name for an alias" do
- christener = Christener.new
- table = Table.new 'users'
- table2 = Table.new 'users', :as => 'friends'
- christener.name_for(table).should == 'users'
- christener.name_for(table2).should == 'friends'
- end
-
- it "returns a unique name for an alias with same name" do
- christener = Christener.new
- table = Table.new 'users'
- table2 = Table.new 'friends', :as => 'users'
- christener.name_for(table).should == 'users'
- christener.name_for(table2).should == 'users_2'
- end
-
- it "returns alias name" do
- christener = Christener.new
- table = Table.new 'users'
- aliaz = Alias.new table
-
- christener.name_for(table).should == 'users'
- christener.name_for(aliaz).should == 'users_2'
- end
-
- it "returns alias first" do
- christener = Christener.new
- table = Table.new 'users'
- aliaz = Alias.new table
-
- christener.name_for(aliaz).should == 'users'
- christener.name_for(table).should == 'users_2'
- end
-
- it "returns externalization name" do
- christener = Christener.new
- table = Table.new 'users'
- ext = Externalization.new table
-
- christener.name_for(table).should == 'users'
- christener.name_for(ext).should == 'users_external'
- end
-
- it "returns aliases externalizations and tables" do
- christener = Christener.new
- table = Table.new 'users'
- aliaz = Alias.new table
- ext = Externalization.new table
-
- christener.name_for(table).should == 'users'
- christener.name_for(aliaz).should == 'users_2'
- christener.name_for(ext).should == 'users_external'
- end
- end
- end
-end
diff --git a/spec/arel/table_spec.rb b/spec/table_spec.rb
index 15f2e024e0..15f2e024e0 100644
--- a/spec/arel/table_spec.rb
+++ b/spec/table_spec.rb
diff --git a/spec/arel/update_manager_spec.rb b/spec/update_manager_spec.rb
index 016b6f69b1..016b6f69b1 100644
--- a/spec/arel/update_manager_spec.rb
+++ b/spec/update_manager_spec.rb
diff --git a/spec/arel/visitors/join_sql_spec.rb b/spec/visitors/join_sql_spec.rb
index 9064dae852..9064dae852 100644
--- a/spec/arel/visitors/join_sql_spec.rb
+++ b/spec/visitors/join_sql_spec.rb
diff --git a/spec/arel/visitors/oracle_spec.rb b/spec/visitors/oracle_spec.rb
index cdf0e3427f..cdf0e3427f 100644
--- a/spec/arel/visitors/oracle_spec.rb
+++ b/spec/visitors/oracle_spec.rb
diff --git a/spec/arel/visitors/to_sql_spec.rb b/spec/visitors/to_sql_spec.rb
index 25642ee947..25642ee947 100644
--- a/spec/arel/visitors/to_sql_spec.rb
+++ b/spec/visitors/to_sql_spec.rb