aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/relations.rb2
-rw-r--r--lib/arel/relations/aggregation.rb2
-rw-r--r--lib/arel/relations/compound.rb6
-rw-r--r--lib/arel/relations/deletion.rb2
-rw-r--r--lib/arel/relations/join.rb6
-rw-r--r--lib/arel/relations/relation.rb8
-rw-r--r--lib/arel/relations/selection.rb21
-rw-r--r--lib/arel/relations/update.rb2
-rw-r--r--lib/arel/relations/where.rb21
9 files changed, 35 insertions, 35 deletions
diff --git a/lib/arel/relations.rb b/lib/arel/relations.rb
index 1a216993e0..b606be3743 100644
--- a/lib/arel/relations.rb
+++ b/lib/arel/relations.rb
@@ -8,7 +8,7 @@ require 'arel/relations/aggregation'
require 'arel/relations/join'
require 'arel/relations/grouping'
require 'arel/relations/projection'
-require 'arel/relations/selection'
+require 'arel/relations/where'
require 'arel/relations/order'
require 'arel/relations/take'
require 'arel/relations/skip'
diff --git a/lib/arel/relations/aggregation.rb b/lib/arel/relations/aggregation.rb
index 7e9cdfe612..66150bff0a 100644
--- a/lib/arel/relations/aggregation.rb
+++ b/lib/arel/relations/aggregation.rb
@@ -6,7 +6,7 @@ module Arel
@relation = relation
end
- def selects
+ def wheres
[]
end
diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb
index f8af190644..a77099e0de 100644
--- a/lib/arel/relations/compound.rb
+++ b/lib/arel/relations/compound.rb
@@ -2,7 +2,7 @@ module Arel
class Compound < Relation
attr_reader :relation
hash_on :relation
- delegate :joins, :selects, :join?, :orders, :groupings, :inserts, :taken,
+ delegate :joins, :wheres, :join?, :inserts, :taken,
:skipped, :name, :aggregation?, :column_for,
:engine, :table, :table_sql,
:to => :relation
@@ -11,8 +11,8 @@ module Arel
@attributes ||= relation.attributes.collect { |a| a.bind(self) }
end
- def selects
- @selects ||= relation.selects.collect { |s| s.bind(self) }
+ def wheres
+ @wheres ||= relation.wheres.collect { |w| w.bind(self) }
end
def groupings
diff --git a/lib/arel/relations/deletion.rb b/lib/arel/relations/deletion.rb
index cd58771846..7edc328e4a 100644
--- a/lib/arel/relations/deletion.rb
+++ b/lib/arel/relations/deletion.rb
@@ -8,7 +8,7 @@ module Arel
[
"DELETE",
"FROM #{table_sql}",
- ("WHERE #{selects.collect(&:to_sql).join('\n\tAND ')}" unless selects.blank? ),
+ ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ),
("LIMIT #{taken}" unless taken.blank? ),
].compact.join("\n")
end
diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb
index 81a157dc10..acad75c817 100644
--- a/lib/arel/relations/join.rb
+++ b/lib/arel/relations/join.rb
@@ -18,7 +18,7 @@ module Arel
join_sql,
relation2.externalize.table_sql(formatter),
("ON" unless predicates.blank?),
- (ons + relation2.externalize.selects).collect { |p| p.bind(environment).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
+ (ons + relation2.externalize.wheres).collect { |p| p.bind(environment).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
].compact.join(" ")
[relation1.joins(environment), this_join, relation2.joins(environment)].compact.join(" ")
end
@@ -29,8 +29,8 @@ module Arel
relation2.externalize.attributes).collect { |a| a.bind(self) }
end
- def selects
- relation1.externalize.selects
+ def wheres
+ relation1.externalize.wheres
end
def ons
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index 9bf7e740aa..1ef7874f39 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -14,7 +14,7 @@ module Arel
"SELECT #{attributes.collect { |a| a.to_sql(Sql::SelectClause.new(self)) }.join(', ')}",
"FROM #{table_sql(Sql::TableReference.new(self))}",
(joins(self) unless joins(self).blank? ),
- ("WHERE #{selects .collect { |s| s.to_sql(Sql::WhereClause.new(self)) }.join("\n\tAND ")}" unless selects.blank? ),
+ ("WHERE #{wheres .collect { |w| w.to_sql(Sql::WhereClause.new(self)) }.join("\n\tAND ")}" unless wheres.blank? ),
("ORDER BY #{orders .collect { |o| o.to_sql(Sql::OrderClause.new(self)) }.join(', ')}" unless orders.blank? ),
("GROUP BY #{groupings.collect { |g| g.to_sql(Sql::GroupClause.new(self)) }.join(', ')}" unless groupings.blank? ),
("LIMIT #{taken}" unless taken.blank? ),
@@ -72,8 +72,8 @@ module Arel
join(other, "LEFT OUTER JOIN")
end
- def select(*predicates)
- predicates.all?(&:blank?) ? self : Selection.new(self, *predicates)
+ def where(*predicates)
+ predicates.all?(&:blank?) ? self : Where.new(self, *predicates)
end
def project(*attributes)
@@ -161,7 +161,7 @@ module Arel
module DefaultOperations
def attributes; [] end
- def selects; [] end
+ def wheres; [] end
def orders; [] end
def inserts; [] end
def groupings; [] end
diff --git a/lib/arel/relations/selection.rb b/lib/arel/relations/selection.rb
deleted file mode 100644
index fc4e94621a..0000000000
--- a/lib/arel/relations/selection.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-module Arel
- class Selection < Compound
- attr_reader :predicate
-
- def initialize(relation, *predicates)
- predicate = predicates.shift
- @relation = predicates.empty?? relation : Selection.new(relation, *predicates)
- @predicate = predicate.bind(@relation)
- end
-
- def selects
- @selects ||= (relation.selects + [predicate]).collect { |p| p.bind(self) }
- end
-
- def ==(other)
- Selection === other and
- relation == other.relation and
- predicate == other.predicate
- end
- end
-end \ No newline at end of file
diff --git a/lib/arel/relations/update.rb b/lib/arel/relations/update.rb
index 8306a83aac..450f06af96 100644
--- a/lib/arel/relations/update.rb
+++ b/lib/arel/relations/update.rb
@@ -12,7 +12,7 @@ module Arel
assignments.collect do |attribute, value|
"#{value.format(attribute)} = #{attribute.format(value)}"
end.join(",\n"),
- ("WHERE #{selects.collect(&:to_sql).join('\n\tAND ')}" unless selects.blank? ),
+ ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ),
("LIMIT #{taken}" unless taken.blank? )
].join("\n")
end
diff --git a/lib/arel/relations/where.rb b/lib/arel/relations/where.rb
new file mode 100644
index 0000000000..ba34846c04
--- /dev/null
+++ b/lib/arel/relations/where.rb
@@ -0,0 +1,21 @@
+module Arel
+ class Where < Compound
+ attr_reader :predicate
+
+ def initialize(relation, *predicates)
+ predicate = predicates.shift
+ @relation = predicates.empty?? relation : Where.new(relation, *predicates)
+ @predicate = predicate.bind(@relation)
+ end
+
+ def wheres
+ @wheres ||= (relation.wheres + [predicate]).collect { |p| p.bind(self) }
+ end
+
+ def ==(other)
+ Where === other and
+ relation == other.relation and
+ predicate == other.predicate
+ end
+ end
+end \ No newline at end of file