aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/attributes/attribute.rb4
-rw-r--r--lib/arel/nodes.rb1
-rw-r--r--lib/arel/nodes/in.rb6
-rw-r--r--lib/arel/visitors/to_sql.rb4
4 files changed, 15 insertions, 0 deletions
diff --git a/lib/arel/attributes/attribute.rb b/lib/arel/attributes/attribute.rb
index fdc64d62e0..ff17d6136c 100644
--- a/lib/arel/attributes/attribute.rb
+++ b/lib/arel/attributes/attribute.rb
@@ -4,6 +4,10 @@ module Arel
def eq other
Nodes::Equality.new self, other
end
+
+ def in other
+ Nodes::In.new self, other
+ end
end
class String < Attribute; end
diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb
index 9dea981a06..d1868adfa9 100644
--- a/lib/arel/nodes.rb
+++ b/lib/arel/nodes.rb
@@ -1,4 +1,5 @@
require 'arel/nodes/equality'
+require 'arel/nodes/in'
require 'arel/nodes/sql_literal'
require 'arel/nodes/select_core'
require 'arel/nodes/select_statement'
diff --git a/lib/arel/nodes/in.rb b/lib/arel/nodes/in.rb
new file mode 100644
index 0000000000..6ccf37a053
--- /dev/null
+++ b/lib/arel/nodes/in.rb
@@ -0,0 +1,6 @@
+module Arel
+ module Nodes
+ class In < Equality
+ end
+ end
+end
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index 736c0ce77b..bb93876595 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -56,6 +56,10 @@ module Arel
quote_table_name o.name
end
+ def visit_Arel_Nodes_In o
+ "#{visit o.left} IN (#{o.right.map { |x| quote visit x }.join ', '})"
+ end
+
def visit_Arel_Nodes_Equality o
"#{visit o.left} = #{quote visit o.right}"
end