aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml18
-rw-r--r--CONTRIBUTING.md100
-rw-r--r--MIT-LICENSE.txt3
-rw-r--r--README.markdown12
-rw-r--r--arel.gemspec2
-rw-r--r--lib/arel/nodes.rb1
-rw-r--r--lib/arel/nodes/binary.rb2
-rw-r--r--lib/arel/nodes/function.rb1
-rw-r--r--lib/arel/nodes/matches.rb4
-rw-r--r--lib/arel/nodes/regexp.rb14
-rw-r--r--lib/arel/predications.rb24
-rw-r--r--lib/arel/visitors/postgresql.rb12
-rw-r--r--test/nodes/test_sum.rb9
-rw-r--r--test/visitors/test_oracle12.rb4
-rw-r--r--test/visitors/test_postgres.rb57
15 files changed, 228 insertions, 35 deletions
diff --git a/.travis.yml b/.travis.yml
index f7ac50ada5..b8a2f0019e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,20 +1,28 @@
language: ruby
-script:
- - "rake test"
+sudo: false
+cache: bundler
+script:
+ - "bundle exec rake test"
- "gem build arel.gemspec"
env:
global:
- JRUBY_OPTS='--dev -J-Xmx1024M'
rvm:
- - rbx
+ - rbx-2
- jruby-head
- 2.0.0
- 2.1
+ - 2.2
- ruby-head
matrix:
- allow_failures:
- - rvm: rbx
+ fast_finish: true
+bundler_args: --jobs 3 --retry 3
notifications:
email: false
irc:
- "irc.freenode.org#rails-contrib"
+ campfire:
+ on_success: change
+ on_failure: always
+ rooms:
+ - secure: "sD4VEjsiNHTb+9LYUy0ZiGu86nH1voUANpmiO62fvO1VPg80ReKv8vNiq285MZVjcPBx9lt1iNx1nNfVlBmDzRI1tWjoyEV5LTuCAt3yQMB5Qpjy3HH1FNgyY2TGjDhIDwgTD6d8+DOCQjj/vgqzWWu1jEJVdac1K5d+dc/uElI="
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..104c05490f
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,100 @@
+Contributing to Arel
+=====================
+
+[![Build Status](https://secure.travis-ci.org/rails/arel.svg?branch=master)](http://travis-ci.org/rails/arel)
+[![Dependency Status](https://gemnasium.com/rails/arel.svg)](https://gemnasium.com/rails/arel)
+
+Arel is work of [many contributors](https://github.com/rails/arel/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/rails/arel/pulls), [propose features and discuss issues](https://github.com/rails/arel/issues).
+
+#### Fork the Project
+
+Fork the [project on Github](https://github.com/rails/arel) and check out your copy.
+
+```
+git clone https://github.com/contributor/arel.git
+cd arel
+git remote add upstream https://github.com/rails/arel.git
+```
+
+#### Create a Topic Branch
+
+Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
+
+```
+git checkout master
+git pull upstream master
+git checkout -b my-feature-branch
+```
+
+#### Bundle Install and Test
+
+Ensure that you can build the project and run tests.
+
+```
+bundle install
+bundle exec rake test
+```
+
+#### Write Tests
+
+Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [test](test).
+
+We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
+
+#### Write Code
+
+Implement your feature or bug fix.
+
+Make sure that `bundle exec rake test` completes without errors.
+
+#### Write Documentation
+
+Document any external behavior in the [README](README.md).
+
+#### Commit Changes
+
+Make sure git knows your name and email address:
+
+```
+git config --global user.name "Your Name"
+git config --global user.email "contributor@example.com"
+```
+
+Writing good commit logs is important. A commit log should describe what changed and why.
+
+```
+git add ...
+git commit
+```
+
+#### Push
+
+```
+git push origin my-feature-branch
+```
+
+#### Make a Pull Request
+
+Go to https://github.com/contributor/arel and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
+
+#### Rebase
+
+If you've been working on a change for a while, rebase with upstream/master.
+
+```
+git fetch upstream
+git rebase upstream/master
+git push origin my-feature-branch -f
+```
+
+#### Check on Your Pull Request
+
+Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
+
+#### Be Patient
+
+It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
+
+#### Thank You
+
+Please do know that we really appreciate and value your time and work. We love you, really.
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt
index 52f1ff7a17..001426b5b0 100644
--- a/MIT-LICENSE.txt
+++ b/MIT-LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2010 Nick Kallen, Bryan Helmkamp, Emilio Tagua, Aaron Patterson
+Copyright (c) 2007-2015 Nick Kallen, Bryan Helmkamp, Emilio Tagua, Aaron Patterson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -18,3 +18,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/README.markdown b/README.markdown
index 76efb2b34a..d570f7855c 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,4 +1,4 @@
-# Arel [![Build Status](https://secure.travis-ci.org/rails/arel.svg?branch=master)](http://travis-ci.org/rails/arel) [![Dependency Status](https://gemnasium.com/rails/arel.svg)](https://gemnasium.com/rails/arel)
+# Arel
* http://github.com/rails/arel
@@ -222,6 +222,12 @@ photos.project(photo_clicks.as("photo_clicks"))
FROM "photos"
```
-### License
+## Contributing to Arel
-Arel is released under the [MIT License](http://opensource.org/licenses/MIT).
+Arel is work of many contributors. You're encouraged to submit pull requests, propose
+features and discuss issues.
+
+See [CONTRIBUTING](CONTRIBUTING.md).
+
+## License
+Arel is released under the [MIT License](http://www.opensource.org/licenses/MIT).
diff --git a/arel.gemspec b/arel.gemspec
index 015c74b446..dd52c89e22 100644
--- a/arel.gemspec
+++ b/arel.gemspec
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--main", "README.markdown"]
s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "README.markdown"]
- s.files = ["History.txt","MIT-LICENSE.txt","README.markdown","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/bind_param.rb","lib/arel/nodes/casted.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"]
+ s.files = ["History.txt","MIT-LICENSE.txt","README.markdown","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/bind_param.rb","lib/arel/nodes/casted.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/oracle12.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"]
s.require_paths = ["lib"]
s.add_development_dependency('minitest', '~> 5.4')
diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb
index 8d61bb320f..0e66d2dd0c 100644
--- a/lib/arel/nodes.rb
+++ b/lib/arel/nodes.rb
@@ -30,6 +30,7 @@ require 'arel/nodes/table_alias'
require 'arel/nodes/infix_operation'
require 'arel/nodes/over'
require 'arel/nodes/matches'
+require 'arel/nodes/regexp'
# nary
require 'arel/nodes/and'
diff --git a/lib/arel/nodes/binary.rb b/lib/arel/nodes/binary.rb
index dddbde1431..763091c267 100644
--- a/lib/arel/nodes/binary.rb
+++ b/lib/arel/nodes/binary.rb
@@ -38,9 +38,7 @@ module Arel
LessThanOrEqual
NotEqual
NotIn
- NotRegexp
Or
- Regexp
Union
UnionAll
Intersect
diff --git a/lib/arel/nodes/function.rb b/lib/arel/nodes/function.rb
index 733a00df46..182dfa7329 100644
--- a/lib/arel/nodes/function.rb
+++ b/lib/arel/nodes/function.rb
@@ -3,6 +3,7 @@ module Arel
class Function < Arel::Nodes::Node
include Arel::Predications
include Arel::WindowPredications
+ include Arel::OrderPredications
attr_accessor :expressions, :alias, :distinct
def initialize expr, aliaz = nil
diff --git a/lib/arel/nodes/matches.rb b/lib/arel/nodes/matches.rb
index 583fb97c9b..0d9c1925dc 100644
--- a/lib/arel/nodes/matches.rb
+++ b/lib/arel/nodes/matches.rb
@@ -2,10 +2,12 @@ module Arel
module Nodes
class Matches < Binary
attr_reader :escape
+ attr_accessor :case_sensitive
- def initialize(left, right, escape = nil)
+ def initialize(left, right, escape = nil, case_sensitive = false)
super(left, right)
@escape = escape && Nodes.build_quoted(escape)
+ @case_sensitive = case_sensitive
end
end
diff --git a/lib/arel/nodes/regexp.rb b/lib/arel/nodes/regexp.rb
new file mode 100644
index 0000000000..784368f5bf
--- /dev/null
+++ b/lib/arel/nodes/regexp.rb
@@ -0,0 +1,14 @@
+module Arel
+ module Nodes
+ class Regexp < Binary
+ attr_accessor :case_sensitive
+
+ def initialize(left, right, case_sensitive = true)
+ super(left, right)
+ @case_sensitive = case_sensitive
+ end
+ end
+
+ class NotRegexp < Regexp; end
+ end
+end
diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb
index b05fc6f99a..1d2b0de235 100644
--- a/lib/arel/predications.rb
+++ b/lib/arel/predications.rb
@@ -118,20 +118,28 @@ Passing a range to `#not_in` is deprecated. Call `#not_between`, instead.
grouping_all :not_in, others
end
- def matches other, escape = nil
- Nodes::Matches.new self, quoted_node(other), escape
+ def matches other, escape = nil, case_sensitive = false
+ Nodes::Matches.new self, quoted_node(other), escape, case_sensitive
end
- def matches_any others, escape = nil
- grouping_any :matches, others, escape
+ def matches_regexp other, case_sensitive = true
+ Nodes::Regexp.new self, quoted_node(other), case_sensitive
end
- def matches_all others, escape = nil
- grouping_all :matches, others, escape
+ def matches_any others, escape = nil, case_sensitive = false
+ grouping_any :matches, others, escape, case_sensitive
end
- def does_not_match other, escape = nil
- Nodes::DoesNotMatch.new self, quoted_node(other), escape
+ def matches_all others, escape = nil, case_sensitive = false
+ grouping_all :matches, others, escape, case_sensitive
+ end
+
+ def does_not_match other, escape = nil, case_sensitive = false
+ Nodes::DoesNotMatch.new self, quoted_node(other), escape, case_sensitive
+ end
+
+ def does_not_match_regexp other, case_sensitive = true
+ Nodes::NotRegexp.new self, quoted_node(other), case_sensitive
end
def does_not_match_any others, escape = nil
diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb
index bd23fc0a47..1ef0261bdd 100644
--- a/lib/arel/visitors/postgresql.rb
+++ b/lib/arel/visitors/postgresql.rb
@@ -4,7 +4,8 @@ module Arel
private
def visit_Arel_Nodes_Matches o, collector
- collector = infix_value o, collector, ' ILIKE '
+ op = o.case_sensitive ? ' LIKE ' : ' ILIKE '
+ collector = infix_value o, collector, op
if o.escape
collector << ' ESCAPE '
visit o.escape, collector
@@ -14,7 +15,8 @@ module Arel
end
def visit_Arel_Nodes_DoesNotMatch o, collector
- collector = infix_value o, collector, ' NOT ILIKE '
+ op = o.case_sensitive ? ' NOT LIKE ' : ' NOT ILIKE '
+ collector = infix_value o, collector, op
if o.escape
collector << ' ESCAPE '
visit o.escape, collector
@@ -24,11 +26,13 @@ module Arel
end
def visit_Arel_Nodes_Regexp o, collector
- infix_value o, collector, ' ~ '
+ op = o.case_sensitive ? ' ~ ' : ' ~* '
+ infix_value o, collector, op
end
def visit_Arel_Nodes_NotRegexp o, collector
- infix_value o, collector, ' !~ '
+ op = o.case_sensitive ? ' !~ ' : ' !~* '
+ infix_value o, collector, op
end
def visit_Arel_Nodes_DistinctOn o, collector
diff --git a/test/nodes/test_sum.rb b/test/nodes/test_sum.rb
index d65cd31d4b..d387e7f9ef 100644
--- a/test/nodes/test_sum.rb
+++ b/test/nodes/test_sum.rb
@@ -21,4 +21,13 @@ describe Arel::Nodes::Sum do
assert_equal 2, array.uniq.size
end
end
+
+ describe 'order' do
+ it 'should order the sum' do
+ table = Arel::Table.new :users
+ table[:id].sum.desc.to_sql.must_be_like %{
+ SUM("users"."id") DESC
+ }
+ end
+ end
end
diff --git a/test/visitors/test_oracle12.rb b/test/visitors/test_oracle12.rb
index cfa130fcab..df0f01b30b 100644
--- a/test/visitors/test_oracle12.rb
+++ b/test/visitors/test_oracle12.rb
@@ -23,7 +23,7 @@ module Arel
it 'generates select options offset then limit' do
stmt = Nodes::SelectStatement.new
stmt.offset = Nodes::Offset.new(1)
- stmt.limit = Nodes::Limit.new(Nodes.build_quoted(10))
+ stmt.limit = Nodes::Limit.new(10)
sql = compile(stmt)
sql.must_be_like "SELECT OFFSET 1 ROWS FETCH FIRST 10 ROWS ONLY"
end
@@ -31,7 +31,7 @@ module Arel
describe 'locking' do
it 'removes limit when locking' do
stmt = Nodes::SelectStatement.new
- stmt.limit = Nodes::Limit.new(Nodes.build_quoted(10))
+ stmt.limit = Nodes::Limit.new(10)
stmt.lock = Nodes::Lock.new(Arel.sql('FOR UPDATE'))
sql = compile(stmt)
sql.must_be_like "SELECT FOR UPDATE"
diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb
index d6de216d91..4b7dbe367f 100644
--- a/test/visitors/test_postgres.rb
+++ b/test/visitors/test_postgres.rb
@@ -53,11 +53,21 @@ module Arel
describe "Nodes::Matches" do
it "should know how to visit" do
node = @table[:name].matches('foo%')
+ node.must_be_kind_of Nodes::Matches
+ node.case_sensitive.must_equal(false)
compile(node).must_be_like %{
"users"."name" ILIKE 'foo%'
}
end
+ it "should know how to visit case sensitive" do
+ node = @table[:name].matches('foo%', nil, true)
+ node.case_sensitive.must_equal(true)
+ compile(node).must_be_like %{
+ "users"."name" LIKE 'foo%'
+ }
+ end
+
it "can handle ESCAPE" do
node = @table[:name].matches('foo!%', '!')
compile(node).must_be_like %{
@@ -77,11 +87,21 @@ module Arel
describe "Nodes::DoesNotMatch" do
it "should know how to visit" do
node = @table[:name].does_not_match('foo%')
+ node.must_be_kind_of Nodes::DoesNotMatch
+ node.case_sensitive.must_equal(false)
compile(node).must_be_like %{
"users"."name" NOT ILIKE 'foo%'
}
end
+ it "should know how to visit case sensitive" do
+ node = @table[:name].does_not_match('foo%', nil, true)
+ node.case_sensitive.must_equal(true)
+ compile(node).must_be_like %{
+ "users"."name" NOT LIKE 'foo%'
+ }
+ end
+
it "can handle ESCAPE" do
node = @table[:name].does_not_match('foo!%', '!')
compile(node).must_be_like %{
@@ -100,34 +120,55 @@ module Arel
describe "Nodes::Regexp" do
it "should know how to visit" do
- node = Arel::Nodes::Regexp.new(@table[:name], Nodes.build_quoted('foo%'))
+ node = @table[:name].matches_regexp('foo.*')
+ node.must_be_kind_of Nodes::Regexp
+ node.case_sensitive.must_equal(true)
compile(node).must_be_like %{
- "users"."name" ~ 'foo%'
+ "users"."name" ~ 'foo.*'
+ }
+ end
+
+ it "can handle case insensitive" do
+ node = @table[:name].matches_regexp('foo.*', false)
+ node.must_be_kind_of Nodes::Regexp
+ node.case_sensitive.must_equal(false)
+ compile(node).must_be_like %{
+ "users"."name" ~* 'foo.*'
}
end
it 'can handle subqueries' do
- subquery = @table.project(:id).where(Arel::Nodes::Regexp.new(@table[:name], Nodes.build_quoted('foo%')))
+ subquery = @table.project(:id).where(@table[:name].matches_regexp('foo.*'))
node = @attr.in subquery
compile(node).must_be_like %{
- "users"."id" IN (SELECT id FROM "users" WHERE "users"."name" ~ 'foo%')
+ "users"."id" IN (SELECT id FROM "users" WHERE "users"."name" ~ 'foo.*')
}
end
end
describe "Nodes::NotRegexp" do
it "should know how to visit" do
- node = Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo%'))
+ node = @table[:name].does_not_match_regexp('foo.*')
+ node.must_be_kind_of Nodes::NotRegexp
+ node.case_sensitive.must_equal(true)
+ compile(node).must_be_like %{
+ "users"."name" !~ 'foo.*'
+ }
+ end
+
+ it "can handle case insensitive" do
+ node = @table[:name].does_not_match_regexp('foo.*', false)
+ node.case_sensitive.must_equal(false)
compile(node).must_be_like %{
- "users"."name" !~ 'foo%'
+ "users"."name" !~* 'foo.*'
}
end
it 'can handle subqueries' do
- subquery = @table.project(:id).where(Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo%')))
+ subquery = @table.project(:id).where(@table[:name].does_not_match_regexp('foo.*'))
node = @attr.in subquery
compile(node).must_be_like %{
- "users"."id" IN (SELECT id FROM "users" WHERE "users"."name" !~ 'foo%')
+ "users"."id" IN (SELECT id FROM "users" WHERE "users"."name" !~ 'foo.*')
}
end
end