From d12580a7ee43dad449a1da208ec60c70c183d7ee Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 16 Aug 2010 14:42:20 -0700 Subject: spec:v1:sqlite3 works for running our specs --- lib/arel/attributes/attribute.rb | 4 ++++ lib/arel/nodes.rb | 1 + lib/arel/nodes/in.rb | 6 ++++++ lib/arel/visitors/to_sql.rb | 4 ++++ 4 files changed, 15 insertions(+) create mode 100644 lib/arel/nodes/in.rb (limited to 'lib/arel') 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 -- cgit v1.2.3