arel 6.0.0.beta1 → 6.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b103196a0f761d65ab71b2ac1e03d779de9e219d
4
- data.tar.gz: 9cb4e0384586df861b130b6f64ad01c85235f1ac
3
+ metadata.gz: 574ad2e118c98249afe11b53301402b5147f4c30
4
+ data.tar.gz: 57ffac4daf00d333d7e7f7e892a1803e000d3c92
5
5
  SHA512:
6
- metadata.gz: cdb5378f5ea5baf01ec44da940498565dadfb2b044047d9ec98f62b5aebe9bc802f79194dcd0936451d41f90238b265e0b534e3fce2ba94951913f9ebf0b9e5f
7
- data.tar.gz: 651a4dba661f193f62c98af603e6a313a354ee772ba5e17e8830b653ac2ef794485f9a1f39ca8ca8702bfd74d66bb12d9b0f436873be5ca885de93033ce7b6d9
6
+ metadata.gz: 9a60726582ea96b9c18f1ffd0dac8930b54c970c1ba31c8f21e7ab52f8bdbc2fdf88b46cd3481b208abe62f5977520680604d13df5caca1568b79b519e8896e6
7
+ data.tar.gz: 70f4af33cc151ca020f80a95520914540f51c66bad7ff2c8dc06963cacda3aa34c2208a0fe88545d4206d5b6408aa69a4ab7c6f4c7ac1a39d58416d09702402b
@@ -0,0 +1,9 @@
1
+ coverage/*
2
+ config/database.yml
3
+ spec/support/fixtures/*database*
4
+ *.DS_Store
5
+ debug.log
6
+ pkg
7
+ .bundle
8
+ *.swp
9
+ Gemfile.lock
@@ -1,3 +1,4 @@
1
+ language: ruby
1
2
  script:
2
3
  - "rake test"
3
4
  - "gem build arel.gemspec"
@@ -6,7 +7,8 @@ rvm:
6
7
  - jruby
7
8
  - 1.9.3
8
9
  - 2.0.0
9
- - 2.1.1
10
+ - 2.1
11
+ - ruby-head
10
12
  matrix:
11
13
  allow_failures:
12
14
  - rvm: rbx
data/Gemfile CHANGED
@@ -1,12 +1,5 @@
1
- # -*- ruby -*-
2
-
3
- # DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
4
-
5
1
  source "https://rubygems.org/"
6
2
 
3
+ gemspec
7
4
 
8
- gem "minitest", "~>5.1", :group => [:development, :test]
9
- gem "rdoc", "~>4.0", :group => [:development, :test]
10
- gem "hoe", "~>3.5", :group => [:development, :test]
11
-
12
- # vim: syntax=ruby
5
+ gem 'rake'
@@ -184,7 +184,7 @@ comments_with_replies = \
184
184
 
185
185
  This will return the reply for the first comment.
186
186
 
187
- [Common Table Expresssions(CTE)](https://en.wikipedia.org/wiki/Common_table_expressions#Common_table_expression) support via:
187
+ [Common Table Expressions(CTE)](https://en.wikipedia.org/wiki/Common_table_expressions#Common_table_expression) support via:
188
188
 
189
189
  Create a `CTE`
190
190
 
data/Rakefile CHANGED
@@ -1,20 +1,15 @@
1
- require "rubygems"
2
- gem 'hoe', '>= 3.3.1'
3
- require 'hoe'
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
4
3
 
5
- Hoe.plugins.delete :rubyforge
6
- Hoe.plugin :minitest
7
- Hoe.plugin :gemspec # `gem install hoe-gemspec`
8
- Hoe.plugin :git # `gem install hoe-git`
9
- Hoe.plugin :bundler # `gem install hoe-bundler`
4
+ specname = "arel.gemspec"
5
+ deps = `git ls-files`.split("\n") - [specname]
10
6
 
11
- Hoe.spec 'arel' do
12
- developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
13
- developer('Bryan Helmkamp', 'bryan@brynary.com')
14
- developer('Emilio Tagua', 'miloops@gmail.com')
15
- developer('Nick Kallen', 'nick@example.org') # FIXME: need Nick's email
7
+ file specname => deps do
8
+ files = `git ls-files`.split("\n") - ["#{specname}.erb"]
16
9
 
17
- self.licenses = ['MIT']
18
- self.readme_file = 'README.markdown'
19
- self.extra_rdoc_files = FileList['README.markdown']
10
+ require 'erb'
11
+
12
+ File.open specname, 'w:utf-8' do |f|
13
+ f.write ERB.new(File.read("#{specname}.erb")).result(binding)
14
+ end
20
15
  end
@@ -1,40 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- # stub: arel 6.0.0.beta1.20140817224534 ruby lib
1
+ # # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "arel"
3
4
 
4
5
  Gem::Specification.new do |s|
5
- s.name = "arel"
6
- s.version = "6.0.0.beta1.20140817224534"
7
-
8
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
9
- s.require_paths = ["lib"]
10
- s.authors = ["Aaron Patterson", "Bryan Helmkamp", "Emilio Tagua", "Nick Kallen"]
11
- s.date = "2014-08-18"
6
+ s.name = "arel"
7
+ s.version = Arel::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Aaron Patterson", "Bryan Helmkamp", "Emilio Tagua", "Nick Kallen"]
10
+ s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com"]
11
+ s.homepage = "https://github.com/rails/arel"
12
12
  s.description = "Arel Really Exasperates Logicians\n\nArel is a SQL AST manager for Ruby. It\n\n1. Simplifies the generation of complex SQL queries\n2. Adapts to various RDBMSes\n\nIt is intended to be a framework framework; that is, you can build your own ORM\nwith it, focusing on innovative object and collection modeling as opposed to\ndatabase compatibility and query generation."
13
- s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com", "nick@example.org"]
14
- s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown"]
15
- s.files = [".autotest", ".gemtest", ".travis.yml", "Gemfile", "History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown", "Rakefile", "arel.gemspec", "lib/arel.rb", "lib/arel/alias_predication.rb", "lib/arel/attributes.rb", "lib/arel/attributes/attribute.rb", "lib/arel/collectors/bind.rb", "lib/arel/collectors/plain_string.rb", "lib/arel/collectors/sql_string.rb", "lib/arel/compatibility/wheres.rb", "lib/arel/crud.rb", "lib/arel/delete_manager.rb", "lib/arel/expressions.rb", "lib/arel/factory_methods.rb", "lib/arel/insert_manager.rb", "lib/arel/math.rb", "lib/arel/nodes.rb", "lib/arel/nodes/and.rb", "lib/arel/nodes/ascending.rb", "lib/arel/nodes/binary.rb", "lib/arel/nodes/count.rb", "lib/arel/nodes/delete_statement.rb", "lib/arel/nodes/descending.rb", "lib/arel/nodes/equality.rb", "lib/arel/nodes/extract.rb", "lib/arel/nodes/false.rb", "lib/arel/nodes/full_outer_join.rb", "lib/arel/nodes/function.rb", "lib/arel/nodes/grouping.rb", "lib/arel/nodes/in.rb", "lib/arel/nodes/infix_operation.rb", "lib/arel/nodes/inner_join.rb", "lib/arel/nodes/insert_statement.rb", "lib/arel/nodes/join_source.rb", "lib/arel/nodes/named_function.rb", "lib/arel/nodes/node.rb", "lib/arel/nodes/outer_join.rb", "lib/arel/nodes/over.rb", "lib/arel/nodes/right_outer_join.rb", "lib/arel/nodes/select_core.rb", "lib/arel/nodes/select_statement.rb", "lib/arel/nodes/sql_literal.rb", "lib/arel/nodes/string_join.rb", "lib/arel/nodes/table_alias.rb", "lib/arel/nodes/terminal.rb", "lib/arel/nodes/true.rb", "lib/arel/nodes/unary.rb", "lib/arel/nodes/unqualified_column.rb", "lib/arel/nodes/update_statement.rb", "lib/arel/nodes/values.rb", "lib/arel/nodes/window.rb", "lib/arel/nodes/with.rb", "lib/arel/order_predications.rb", "lib/arel/predications.rb", "lib/arel/select_manager.rb", "lib/arel/table.rb", "lib/arel/tree_manager.rb", "lib/arel/update_manager.rb", "lib/arel/visitors.rb", "lib/arel/visitors/bind_substitute.rb", "lib/arel/visitors/bind_visitor.rb", "lib/arel/visitors/depth_first.rb", "lib/arel/visitors/dot.rb", "lib/arel/visitors/ibm_db.rb", "lib/arel/visitors/informix.rb", "lib/arel/visitors/mssql.rb", "lib/arel/visitors/mysql.rb", "lib/arel/visitors/oracle.rb", "lib/arel/visitors/postgresql.rb", "lib/arel/visitors/reduce.rb", "lib/arel/visitors/sqlite.rb", "lib/arel/visitors/to_sql.rb", "lib/arel/visitors/visitor.rb", "lib/arel/visitors/where_sql.rb", "lib/arel/window_predications.rb", "test/attributes/test_attribute.rb", "test/collectors/test_bind_collector.rb", "test/collectors/test_sql_string.rb", "test/helper.rb", "test/nodes/test_and.rb", "test/nodes/test_as.rb", "test/nodes/test_ascending.rb", "test/nodes/test_bin.rb", "test/nodes/test_count.rb", "test/nodes/test_delete_statement.rb", "test/nodes/test_descending.rb", "test/nodes/test_distinct.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_false.rb", "test/nodes/test_grouping.rb", "test/nodes/test_infix_operation.rb", "test/nodes/test_insert_statement.rb", "test/nodes/test_named_function.rb", "test/nodes/test_node.rb", "test/nodes/test_not.rb", "test/nodes/test_or.rb", "test/nodes/test_over.rb", "test/nodes/test_select_core.rb", "test/nodes/test_select_statement.rb", "test/nodes/test_sql_literal.rb", "test/nodes/test_sum.rb", "test/nodes/test_table_alias.rb", "test/nodes/test_true.rb", "test/nodes/test_update_statement.rb", "test/nodes/test_window.rb", "test/support/fake_record.rb", "test/test_attributes.rb", "test/test_crud.rb", "test/test_delete_manager.rb", "test/test_factory_methods.rb", "test/test_insert_manager.rb", "test/test_select_manager.rb", "test/test_table.rb", "test/test_update_manager.rb", "test/visitors/test_bind_visitor.rb", "test/visitors/test_depth_first.rb", "test/visitors/test_dispatch_contamination.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/test_mssql.rb", "test/visitors/test_mysql.rb", "test/visitors/test_oracle.rb", "test/visitors/test_postgres.rb", "test/visitors/test_sqlite.rb", "test/visitors/test_to_sql.rb"]
16
- s.homepage = "http://github.com/rails/arel"
17
- s.licenses = ["MIT"]
13
+ s.summary = "Arel Really Exasperates Logicians Arel is a SQL AST manager for Ruby"
14
+ s.license = %q{MIT}
15
+
18
16
  s.rdoc_options = ["--main", "README.markdown"]
19
- s.rubygems_version = "2.2.2"
20
- s.summary = "Arel Really Exasperates Logicians Arel is a SQL AST manager for Ruby"
21
- s.test_files = ["test/attributes/test_attribute.rb", "test/collectors/test_bind_collector.rb", "test/collectors/test_sql_string.rb", "test/nodes/test_and.rb", "test/nodes/test_as.rb", "test/nodes/test_ascending.rb", "test/nodes/test_bin.rb", "test/nodes/test_count.rb", "test/nodes/test_delete_statement.rb", "test/nodes/test_descending.rb", "test/nodes/test_distinct.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_false.rb", "test/nodes/test_grouping.rb", "test/nodes/test_infix_operation.rb", "test/nodes/test_insert_statement.rb", "test/nodes/test_named_function.rb", "test/nodes/test_node.rb", "test/nodes/test_not.rb", "test/nodes/test_or.rb", "test/nodes/test_over.rb", "test/nodes/test_select_core.rb", "test/nodes/test_select_statement.rb", "test/nodes/test_sql_literal.rb", "test/nodes/test_sum.rb", "test/nodes/test_table_alias.rb", "test/nodes/test_true.rb", "test/nodes/test_update_statement.rb", "test/nodes/test_window.rb", "test/test_attributes.rb", "test/test_crud.rb", "test/test_delete_manager.rb", "test/test_factory_methods.rb", "test/test_insert_manager.rb", "test/test_select_manager.rb", "test/test_table.rb", "test/test_update_manager.rb", "test/visitors/test_bind_visitor.rb", "test/visitors/test_depth_first.rb", "test/visitors/test_dispatch_contamination.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/test_mssql.rb", "test/visitors/test_mysql.rb", "test/visitors/test_oracle.rb", "test/visitors/test_postgres.rb", "test/visitors/test_sqlite.rb", "test/visitors/test_to_sql.rb"]
17
+ s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "README.markdown"]
22
18
 
23
- if s.respond_to? :specification_version then
24
- s.specification_version = 4
19
+ s.files = [".gitignore",".travis.yml","Gemfile","History.txt","MIT-LICENSE.txt","README.markdown","Rakefile","arel.gemspec","lib/arel.rb","lib/arel/alias_predication.rb","lib/arel/attributes.rb","lib/arel/attributes/attribute.rb","lib/arel/collectors/bind.rb","lib/arel/collectors/plain_string.rb","lib/arel/collectors/sql_string.rb","lib/arel/compatibility/wheres.rb","lib/arel/crud.rb","lib/arel/delete_manager.rb","lib/arel/expressions.rb","lib/arel/factory_methods.rb","lib/arel/insert_manager.rb","lib/arel/math.rb","lib/arel/nodes.rb","lib/arel/nodes/and.rb","lib/arel/nodes/ascending.rb","lib/arel/nodes/binary.rb","lib/arel/nodes/count.rb","lib/arel/nodes/delete_statement.rb","lib/arel/nodes/descending.rb","lib/arel/nodes/equality.rb","lib/arel/nodes/extract.rb","lib/arel/nodes/false.rb","lib/arel/nodes/full_outer_join.rb","lib/arel/nodes/function.rb","lib/arel/nodes/grouping.rb","lib/arel/nodes/in.rb","lib/arel/nodes/infix_operation.rb","lib/arel/nodes/inner_join.rb","lib/arel/nodes/insert_statement.rb","lib/arel/nodes/join_source.rb","lib/arel/nodes/matches.rb","lib/arel/nodes/named_function.rb","lib/arel/nodes/node.rb","lib/arel/nodes/outer_join.rb","lib/arel/nodes/over.rb","lib/arel/nodes/right_outer_join.rb","lib/arel/nodes/select_core.rb","lib/arel/nodes/select_statement.rb","lib/arel/nodes/sql_literal.rb","lib/arel/nodes/string_join.rb","lib/arel/nodes/table_alias.rb","lib/arel/nodes/terminal.rb","lib/arel/nodes/true.rb","lib/arel/nodes/unary.rb","lib/arel/nodes/unqualified_column.rb","lib/arel/nodes/update_statement.rb","lib/arel/nodes/values.rb","lib/arel/nodes/window.rb","lib/arel/nodes/with.rb","lib/arel/order_predications.rb","lib/arel/predications.rb","lib/arel/select_manager.rb","lib/arel/table.rb","lib/arel/tree_manager.rb","lib/arel/update_manager.rb","lib/arel/visitors.rb","lib/arel/visitors/bind_substitute.rb","lib/arel/visitors/bind_visitor.rb","lib/arel/visitors/depth_first.rb","lib/arel/visitors/dot.rb","lib/arel/visitors/ibm_db.rb","lib/arel/visitors/informix.rb","lib/arel/visitors/mssql.rb","lib/arel/visitors/mysql.rb","lib/arel/visitors/oracle.rb","lib/arel/visitors/postgresql.rb","lib/arel/visitors/reduce.rb","lib/arel/visitors/sqlite.rb","lib/arel/visitors/to_sql.rb","lib/arel/visitors/visitor.rb","lib/arel/visitors/where_sql.rb","lib/arel/window_predications.rb","test/attributes/test_attribute.rb","test/collectors/test_bind_collector.rb","test/collectors/test_sql_string.rb","test/helper.rb","test/nodes/test_and.rb","test/nodes/test_as.rb","test/nodes/test_ascending.rb","test/nodes/test_bin.rb","test/nodes/test_binary.rb","test/nodes/test_count.rb","test/nodes/test_delete_statement.rb","test/nodes/test_descending.rb","test/nodes/test_distinct.rb","test/nodes/test_equality.rb","test/nodes/test_extract.rb","test/nodes/test_false.rb","test/nodes/test_grouping.rb","test/nodes/test_infix_operation.rb","test/nodes/test_insert_statement.rb","test/nodes/test_named_function.rb","test/nodes/test_node.rb","test/nodes/test_not.rb","test/nodes/test_or.rb","test/nodes/test_over.rb","test/nodes/test_select_core.rb","test/nodes/test_select_statement.rb","test/nodes/test_sql_literal.rb","test/nodes/test_sum.rb","test/nodes/test_table_alias.rb","test/nodes/test_true.rb","test/nodes/test_update_statement.rb","test/nodes/test_window.rb","test/support/fake_record.rb","test/test_attributes.rb","test/test_crud.rb","test/test_delete_manager.rb","test/test_factory_methods.rb","test/test_insert_manager.rb","test/test_select_manager.rb","test/test_table.rb","test/test_update_manager.rb","test/visitors/test_bind_visitor.rb","test/visitors/test_depth_first.rb","test/visitors/test_dispatch_contamination.rb","test/visitors/test_dot.rb","test/visitors/test_ibm_db.rb","test/visitors/test_informix.rb","test/visitors/test_mssql.rb","test/visitors/test_mysql.rb","test/visitors/test_oracle.rb","test/visitors/test_postgres.rb","test/visitors/test_sqlite.rb","test/visitors/test_to_sql.rb"]
20
+ s.require_paths = ["lib"]
25
21
 
26
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<minitest>, ["~> 5.4"])
28
- s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
29
- s.add_development_dependency(%q<hoe>, ["~> 3.12"])
30
- else
31
- s.add_dependency(%q<minitest>, ["~> 5.4"])
32
- s.add_dependency(%q<rdoc>, ["~> 4.0"])
33
- s.add_dependency(%q<hoe>, ["~> 3.12"])
34
- end
35
- else
36
- s.add_dependency(%q<minitest>, ["~> 5.4"])
37
- s.add_dependency(%q<rdoc>, ["~> 4.0"])
38
- s.add_dependency(%q<hoe>, ["~> 3.12"])
39
- end
22
+ s.add_development_dependency('minitest', '~> 5.4')
23
+ s.add_development_dependency('rdoc', '~> 4.0')
40
24
  end
@@ -21,7 +21,7 @@ require 'arel/delete_manager'
21
21
  require 'arel/nodes'
22
22
 
23
23
  module Arel
24
- VERSION = '6.0.0.beta1'
24
+ VERSION = '6.0.0.beta2'
25
25
 
26
26
  def self.sql raw_sql
27
27
  Arel::Nodes::SqlLiteral.new raw_sql
@@ -28,6 +28,7 @@ require 'arel/nodes/delete_statement'
28
28
  require 'arel/nodes/table_alias'
29
29
  require 'arel/nodes/infix_operation'
30
30
  require 'arel/nodes/over'
31
+ require 'arel/nodes/matches'
31
32
 
32
33
  # nary
33
34
  require 'arel/nodes/and'
@@ -16,7 +16,7 @@ module Arel
16
16
  end
17
17
 
18
18
  def hash
19
- [@left, @right].hash
19
+ [self.class, @left, @right].hash
20
20
  end
21
21
 
22
22
  def eql? other
@@ -31,13 +31,11 @@ module Arel
31
31
  As
32
32
  Assignment
33
33
  Between
34
- DoesNotMatch
35
34
  GreaterThan
36
35
  GreaterThanOrEqual
37
36
  Join
38
37
  LessThan
39
38
  LessThanOrEqual
40
- Matches
41
39
  NotEqual
42
40
  NotIn
43
41
  NotRegexp
@@ -1,30 +1,23 @@
1
1
  module Arel
2
2
  module Nodes
3
3
  class Extract < Arel::Nodes::Unary
4
+ include Arel::AliasPredication
4
5
  include Arel::Predications
5
6
 
6
7
  attr_accessor :field
7
- attr_accessor :alias
8
8
 
9
- def initialize expr, field, aliaz = nil
9
+ def initialize expr, field
10
10
  super(expr)
11
11
  @field = field
12
- @alias = aliaz && SqlLiteral.new(aliaz)
13
- end
14
-
15
- def as aliaz
16
- self.alias = SqlLiteral.new(aliaz)
17
- self
18
12
  end
19
13
 
20
14
  def hash
21
- super ^ [@field, @alias].hash
15
+ super ^ @field.hash
22
16
  end
23
17
 
24
18
  def eql? other
25
19
  super &&
26
- self.field == other.field &&
27
- self.alias == other.alias
20
+ self.field == other.field
28
21
  end
29
22
  alias :== :eql?
30
23
  end
@@ -0,0 +1,14 @@
1
+ module Arel
2
+ module Nodes
3
+ class Matches < Binary
4
+ attr_reader :escape
5
+
6
+ def initialize(left, right, escape = nil)
7
+ super(left, right)
8
+ @escape = escape && Nodes.build_quoted(escape)
9
+ end
10
+ end
11
+
12
+ class DoesNotMatch < Matches; end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module Arel
2
2
  module Predications
3
3
  def not_eq other
4
- Nodes::NotEqual.new self, Nodes.build_quoted(other, self)
4
+ Nodes::NotEqual.new self, quoted_node(other)
5
5
  end
6
6
 
7
7
  def not_eq_any others
@@ -13,7 +13,7 @@ module Arel
13
13
  end
14
14
 
15
15
  def eq other
16
- Nodes::Equality.new self, Nodes.build_quoted(other, self)
16
+ Nodes::Equality.new self, quoted_node(other)
17
17
  end
18
18
 
19
19
  def eq_any others
@@ -21,7 +21,27 @@ module Arel
21
21
  end
22
22
 
23
23
  def eq_all others
24
- grouping_all :eq, others.map { |x| Nodes.build_quoted(x, self) }
24
+ grouping_all :eq, quoted_array(others)
25
+ end
26
+
27
+ def between other
28
+ if other.begin == -Float::INFINITY
29
+ if other.end == Float::INFINITY
30
+ not_in([])
31
+ elsif other.exclude_end?
32
+ lt(other.end)
33
+ else
34
+ lteq(other.end)
35
+ end
36
+ elsif other.end == Float::INFINITY
37
+ gteq(other.begin)
38
+ elsif other.exclude_end?
39
+ gteq(other.begin).and(lt(other.end))
40
+ else
41
+ left = quoted_node(other.begin)
42
+ right = quoted_node(other.end)
43
+ Nodes::Between.new(self, left.and(right))
44
+ end
25
45
  end
26
46
 
27
47
  def in other
@@ -29,27 +49,16 @@ module Arel
29
49
  when Arel::SelectManager
30
50
  Arel::Nodes::In.new(self, other.ast)
31
51
  when Range
32
- if other.begin == -Float::INFINITY
33
- if other.end == Float::INFINITY
34
- Nodes::NotIn.new self, []
35
- elsif other.exclude_end?
36
- Nodes::LessThan.new(self, Nodes.build_quoted(other.end, self))
37
- else
38
- Nodes::LessThanOrEqual.new(self, Nodes.build_quoted(other.end, self))
39
- end
40
- elsif other.end == Float::INFINITY
41
- Nodes::GreaterThanOrEqual.new(self, Nodes.build_quoted(other.begin, self))
42
- elsif other.exclude_end?
43
- left = Nodes::GreaterThanOrEqual.new(self, Nodes.build_quoted(other.begin, self))
44
- right = Nodes::LessThan.new(self, Nodes.build_quoted(other.end, self))
45
- Nodes::And.new [left, right]
46
- else
47
- Nodes::Between.new(self, Nodes::And.new([Nodes.build_quoted(other.begin, self), Nodes.build_quoted(other.end, self)]))
52
+ if $VERBOSE
53
+ warn <<-eowarn
54
+ Passing a range to `#in` is deprecated. Call `#between`, instead.
55
+ eowarn
48
56
  end
57
+ between(other)
49
58
  when Array
50
- Nodes::In.new self, other.map { |x| Nodes.build_quoted(x, self) }
59
+ Nodes::In.new self, quoted_array(other)
51
60
  else
52
- Nodes::In.new self, Nodes.build_quoted(other, self)
61
+ Nodes::In.new self, quoted_node(other)
53
62
  end
54
63
  end
55
64
 
@@ -61,34 +70,43 @@ module Arel
61
70
  grouping_all :in, others
62
71
  end
63
72
 
73
+ def not_between other
74
+ if other.begin == -Float::INFINITY # The range begins with negative infinity
75
+ if other.end == Float::INFINITY
76
+ self.in([])
77
+ elsif other.exclude_end?
78
+ gteq(other.end)
79
+ else
80
+ gt(other.end)
81
+ end
82
+ elsif other.end == Float::INFINITY
83
+ lt(other.begin)
84
+ else
85
+ left = lt(other.begin)
86
+ right = if other.exclude_end?
87
+ gteq(other.end)
88
+ else
89
+ gt(other.end)
90
+ end
91
+ left.or(right)
92
+ end
93
+ end
94
+
64
95
  def not_in other
65
96
  case other
66
97
  when Arel::SelectManager
67
98
  Arel::Nodes::NotIn.new(self, other.ast)
68
99
  when Range
69
- if other.begin == -Float::INFINITY # The range begins with negative infinity
70
- if other.end == Float::INFINITY
71
- Nodes::In.new self, [] # The range is infinite, so return an empty range
72
- elsif other.exclude_end?
73
- Nodes::GreaterThanOrEqual.new(self, Nodes.build_quoted(other.end, self))
74
- else
75
- Nodes::GreaterThan.new(self, Nodes.build_quoted(other.end, self))
76
- end
77
- elsif other.end == Float::INFINITY
78
- Nodes::LessThan.new(self, Nodes.build_quoted(other.begin, self))
79
- else
80
- left = Nodes::LessThan.new(self, Nodes.build_quoted(other.begin, self))
81
- if other.exclude_end?
82
- right = Nodes::GreaterThanOrEqual.new(self, Nodes.build_quoted(other.end, self))
83
- else
84
- right = Nodes::GreaterThan.new(self, Nodes.build_quoted(other.end, self))
85
- end
86
- Nodes::Or.new left, right
100
+ if $VERBOSE
101
+ warn <<-eowarn
102
+ Passing a range to `#not_in` is deprecated. Call `#not_between`, instead.
103
+ eowarn
87
104
  end
105
+ not_between(other)
88
106
  when Array
89
- Nodes::NotIn.new self, other.map { |x| Nodes.build_quoted(x, self) }
107
+ Nodes::NotIn.new self, quoted_array(other)
90
108
  else
91
- Nodes::NotIn.new self, Nodes.build_quoted(other, self)
109
+ Nodes::NotIn.new self, quoted_node(other)
92
110
  end
93
111
  end
94
112
 
@@ -100,32 +118,32 @@ module Arel
100
118
  grouping_all :not_in, others
101
119
  end
102
120
 
103
- def matches other
104
- Nodes::Matches.new self, Nodes.build_quoted(other, self)
121
+ def matches other, escape = nil
122
+ Nodes::Matches.new self, quoted_node(other), escape
105
123
  end
106
124
 
107
- def matches_any others
108
- grouping_any :matches, others
125
+ def matches_any others, escape = nil
126
+ grouping_any :matches, others, escape
109
127
  end
110
128
 
111
- def matches_all others
112
- grouping_all :matches, others
129
+ def matches_all others, escape = nil
130
+ grouping_all :matches, others, escape
113
131
  end
114
132
 
115
- def does_not_match other
116
- Nodes::DoesNotMatch.new self, Nodes.build_quoted(other, self)
133
+ def does_not_match other, escape = nil
134
+ Nodes::DoesNotMatch.new self, quoted_node(other), escape
117
135
  end
118
136
 
119
- def does_not_match_any others
120
- grouping_any :does_not_match, others
137
+ def does_not_match_any others, escape = nil
138
+ grouping_any :does_not_match, others, escape
121
139
  end
122
140
 
123
- def does_not_match_all others
124
- grouping_all :does_not_match, others
141
+ def does_not_match_all others, escape = nil
142
+ grouping_all :does_not_match, others, escape
125
143
  end
126
144
 
127
145
  def gteq right
128
- Nodes::GreaterThanOrEqual.new self, Nodes.build_quoted(right, self)
146
+ Nodes::GreaterThanOrEqual.new self, quoted_node(right)
129
147
  end
130
148
 
131
149
  def gteq_any others
@@ -137,7 +155,7 @@ module Arel
137
155
  end
138
156
 
139
157
  def gt right
140
- Nodes::GreaterThan.new self, Nodes.build_quoted(right, self)
158
+ Nodes::GreaterThan.new self, quoted_node(right)
141
159
  end
142
160
 
143
161
  def gt_any others
@@ -149,7 +167,7 @@ module Arel
149
167
  end
150
168
 
151
169
  def lt right
152
- Nodes::LessThan.new self, right
170
+ Nodes::LessThan.new self, quoted_node(right)
153
171
  end
154
172
 
155
173
  def lt_any others
@@ -161,7 +179,7 @@ module Arel
161
179
  end
162
180
 
163
181
  def lteq right
164
- Nodes::LessThanOrEqual.new self, right
182
+ Nodes::LessThanOrEqual.new self, quoted_node(right)
165
183
  end
166
184
 
167
185
  def lteq_any others
@@ -174,15 +192,24 @@ module Arel
174
192
 
175
193
  private
176
194
 
177
- def grouping_any method_id, others
178
- nodes = others.map {|expr| send(method_id, expr)}
195
+ def grouping_any method_id, others, *extras
196
+ nodes = others.map {|expr| send(method_id, expr, *extras)}
179
197
  Nodes::Grouping.new nodes.inject { |memo,node|
180
198
  Nodes::Or.new(memo, node)
181
199
  }
182
200
  end
183
201
 
184
- def grouping_all method_id, others
185
- Nodes::Grouping.new Nodes::And.new(others.map {|expr| send(method_id, expr)})
202
+ def grouping_all method_id, others, *extras
203
+ nodes = others.map {|expr| send(method_id, expr, *extras)}
204
+ Nodes::Grouping.new Nodes::And.new(nodes)
205
+ end
206
+
207
+ def quoted_node(other)
208
+ Nodes.build_quoted(other, self)
209
+ end
210
+
211
+ def quoted_array(others)
212
+ others.map { |v| quoted_node(v) }
186
213
  end
187
214
  end
188
215
  end