From d12580a7ee43dad449a1da208ec60c70c183d7ee Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 16 Aug 2010 14:42:20 -0700 Subject: [PATCH] spec:v1:sqlite3 works for running our specs --- Rakefile | 12 ++++++++++++ lib/arel/attributes/attribute.rb | 4 ++++ lib/arel/nodes.rb | 1 + lib/arel/nodes/in.rb | 6 ++++++ lib/arel/visitors/to_sql.rb | 4 ++++ 5 files changed, 27 insertions(+) create mode 100644 lib/arel/nodes/in.rb diff --git a/Rakefile b/Rakefile index 40fb0afc07..a6f80222c8 100644 --- a/Rakefile +++ b/Rakefile @@ -41,6 +41,18 @@ else desc "Run specs with the #{adapter} database adapter" task adapter => "set_env_for_#{adapter}" + + namespace :v1 do + Spec::Rake::SpecTask.new(adapter) do |t| + t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""] + t.libs << "#{File.dirname(__FILE__)}/spec" + t.warning = true + t.spec_files = FileList['spec/arel/**/*_spec.rb'] + end + + desc "Run specs with the #{adapter} database adapter" + task adapter => "set_env_for_#{adapter}" + end end end 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