Merge pull request #1013 from daflip/dont-escape-periods-in-mysql2
Don't escape period characters with wildcard searches in mysql2
This commit is contained in:
commit
7836838a07
|
@ -102,8 +102,11 @@ module Ransack
|
|||
# replace % \ to \% \\
|
||||
def escape_wildcards(unescaped)
|
||||
case ActiveRecord::Base.connection.adapter_name
|
||||
when "Mysql2".freeze, "PostgreSQL".freeze
|
||||
# Necessary for PostgreSQL and MySQL
|
||||
when "Mysql2".freeze
|
||||
# Necessary for MySQL
|
||||
unescaped.to_s.gsub(/([\\%_])/, '\\\\\\1')
|
||||
when "PostgreSQL".freeze
|
||||
# Necessary for PostgreSQL
|
||||
unescaped.to_s.gsub(/([\\%_.])/, '\\\\\\1')
|
||||
else
|
||||
unescaped
|
||||
|
|
|
@ -126,7 +126,7 @@ module Ransack
|
|||
(if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
|
||||
/"people"."name" ILIKE '%\\%\\.\\_\\\\%'/
|
||||
elsif ActiveRecord::Base.connection.adapter_name == "Mysql2"
|
||||
/`people`.`name` LIKE '%\\\\%\\\\.\\\\_\\\\\\\\%'/
|
||||
/`people`.`name` LIKE '%\\\\%.\\\\_\\\\\\\\%'/
|
||||
else
|
||||
/"people"."name" LIKE '%%._\\%'/
|
||||
end) do
|
||||
|
@ -145,7 +145,7 @@ module Ransack
|
|||
(if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
|
||||
/"people"."name" NOT ILIKE '%\\%\\.\\_\\\\%'/
|
||||
elsif ActiveRecord::Base.connection.adapter_name == "Mysql2"
|
||||
/`people`.`name` NOT LIKE '%\\\\%\\\\.\\\\_\\\\\\\\%'/
|
||||
/`people`.`name` NOT LIKE '%\\\\%.\\\\_\\\\\\\\%'/
|
||||
else
|
||||
/"people"."name" NOT LIKE '%%._\\%'/
|
||||
end) do
|
||||
|
|
Loading…
Reference in New Issue