diff options
author | Keenan Brock <keenan@thebrocks.net> | 2015-12-05 19:13:05 -0500 |
---|---|---|
committer | Keenan Brock <keenan@thebrocks.net> | 2015-12-05 19:13:31 -0500 |
commit | 193d2ad2147a5cd1de44f2d57f4f3bd65e161293 (patch) | |
tree | ac0708511c1c52d29d57d0469307a87e91a56c54 /test | |
parent | 508a6783c8f75742ac64e5073b3b211b0c15662a (diff) | |
download | rails-193d2ad2147a5cd1de44f2d57f4f3bd65e161293.tar.gz rails-193d2ad2147a5cd1de44f2d57f4f3bd65e161293.tar.bz2 rails-193d2ad2147a5cd1de44f2d57f4f3bd65e161293.zip |
Add case sensitive regexp
Explicitly declare if this is case sensitive or not
currently postgres assumes case insensitive regexp
no other databases support regexps
Diffstat (limited to 'test')
-rw-r--r-- | test/visitors/test_postgres.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb index d00aa1c100..e6fd4cd0da 100644 --- a/test/visitors/test_postgres.rb +++ b/test/visitors/test_postgres.rb @@ -120,6 +120,13 @@ module Arel } end + it "can handle case insensitive" do + node = Arel::Nodes::Regexp.new(@table[:name], Nodes.build_quoted('foo%'), 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%'))) node = @attr.in subquery @@ -137,6 +144,13 @@ module Arel } end + it "can handle case insensitive" do + node = Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo%'), false) + compile(node).must_be_like %{ + "users"."name" !~* 'foo%' + } + end + it 'can handle subqueries' do subquery = @table.project(:id).where(Arel::Nodes::NotRegexp.new(@table[:name], Nodes.build_quoted('foo%'))) node = @attr.in subquery |