Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support trilogy mysql adapter #67

Merged
merged 1 commit into from
Sep 23, 2023

Conversation

dhruvCW
Copy link
Contributor

@dhruvCW dhruvCW commented Aug 29, 2023

Check if the adapter is mysql or trilogy to decide if the fingerprinting should be mysql or postgresql. trilogy is a new mysql adapter for ruby.

more info here https://github.com/trilogy-libraries

trilogy will also be a bundled adapter from rails 7.1

@dhruvCW
Copy link
Contributor Author

dhruvCW commented Aug 29, 2023

@charkost would be awesome if we could release this once merged 😁 🍻

@BrianHawley
Copy link

Hotpatch initializer version:

# frozen_string_literal: true

if defined?(Prosopite)
  begin
    Prosopite.fingerprint("select 1")
  rescue LoadError
    # Add support for the trilogy adapter.
    Prosopite.module_exec do
      class << self
        def fingerprint(query)
          if ActiveRecord::Base.connection.adapter_name.downcase.start_with?("mysql", "trilogy")
            mysql_fingerprint(query)
          else
            begin
              require "pg_query"
            rescue LoadError => e
              msg = "Could not load the 'pg_query' gem. Add `gem 'pg_query'` to your Gemfile"
              raise LoadError, msg, e.backtrace
            end
            PgQuery.fingerprint(query)
          end
        end
      end
    end
  end
end

@charkost charkost merged commit 484a90e into charkost:main Sep 23, 2023
4 checks passed
@charkost
Copy link
Owner

Thanks @dhruvCW !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants