ransack
ransack copied to clipboard
Support for Trilogy database adapter
When wildcard matching, ransack takes care to escape any special characters in the search term. This is from lib/ransack/constants.rb
:
module_function
# replace % \ to \% \\
def escape_wildcards(unescaped)
case ActiveRecord::Base.connection.adapter_name
when "Mysql2".freeze
# Necessary for MySQL
unescaped.to_s.gsub(/([\\%_])/, '\\\\\\1')
when "PostgreSQL".freeze
# Necessary for PostgreSQL
unescaped.to_s.gsub(/([\\%_.])/, '\\\\\\1')
else
unescaped
end
end
end
There is a new MySQL adapter called Trilogy: https://github.blog/2022-08-25-introducing-trilogy-a-new-database-adapter-for-ruby-on-rails/
Can we get support for this adapter? I'm not sure how much of the ransack code would be impacted, this (wildcard search escaping) just happened to be the thing I ran into.