Commit ec9355708cba2363111512338f03d870c23fa64d

Authored by Andrew Kane
1 parent 1257fd79

Added comment about like [skip ci]

Showing 1 changed file with 5 additions and 0 deletions   Show diff stats
lib/searchkick/query.rb
... ... @@ -936,6 +936,11 @@ module Searchkick
936 936 }
937 937 }
938 938 when :like
  939 + # based on Postgres
  940 + # https://www.postgresql.org/docs/current/functions-matching.html
  941 + # % matches zero or more characters
  942 + # _ matches one character
  943 + # \ is escape character
939 944 regex = Regexp.escape(op_value).gsub(/(?<!\\)%/, ".*").gsub(/(?<!\\)_/, ".").gsub("\\%", "%").gsub("\\_", "_")
940 945 filters << {regexp: {field => {value: regex}}}
941 946 when :prefix
... ...