From 193d2ad2147a5cd1de44f2d57f4f3bd65e161293 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Sat, 5 Dec 2015 19:13:05 -0500 Subject: Add case sensitive regexp Explicitly declare if this is case sensitive or not currently postgres assumes case insensitive regexp no other databases support regexps --- test/visitors/test_postgres.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') 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 -- cgit v1.2.3