From 6664a9ea3fc8bf70210937bfd619666672bde220 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 18 Apr 2018 01:54:12 -0700 Subject: [PATCH] Only use standard operators for Ruby regexp - #1117 --- lib/searchkick/query.rb | 2 +- test/where_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 8f5174b..f1ed67c 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -900,7 +900,7 @@ module Searchkick elsif value.nil? {bool: {must_not: {exists: {field: field}}}} elsif value.is_a?(Regexp) - {regexp: {field => {value: value.source}}} + {regexp: {field => {value: value.source, flags: "NONE"}}} else {term: {field => value}} end diff --git a/test/where_test.rb b/test/where_test.rb index 0f195c0..d323f8d 100644 --- a/test/where_test.rb +++ b/test/where_test.rb @@ -79,6 +79,11 @@ class WhereTest < Minitest::Test assert_search "*", ["Product A"], where: {name: {regexp: "Pro.+"}} end + def test_special_regexp + store_names ["Product ", "Item "] + assert_search "*", ["Product "], where: {name: /Pro.+<.+/} + end + def test_where_string store [ {name: "Product A", color: "RED"} -- libgit2 0.21.0