activerecord-hackery / ransack

Object-based searching.
https://activerecord-hackery.github.io/ransack/
MIT License
5.61k stars 782 forks source link

Support for Trilogy database adapter #1500

Open navels opened 6 days ago

navels commented 6 days ago

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.