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

Switching from mysql2 to trilogy in Rails #1

Closed
Kareem-Emad opened this issue Dec 17, 2021 · 5 comments
Closed

Switching from mysql2 to trilogy in Rails #1

Kareem-Emad opened this issue Dec 17, 2021 · 5 comments

Comments

@Kareem-Emad
Copy link

Kareem-Emad commented Dec 17, 2021

I'm trying to integrate trilogy in a toy project I was working on with mysql2 without doing a lot of changes. Since I was using ActiveRecord to write my queries, I thought it would be nice if we could simply replace the adapter attrribute in config/database,yml from mysql2 to be trilogy, but it didn't work

.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': Could not load the 'trilogy' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile. (LoadError)

So I was wondering if there is a way to add trilogy as an ActiveRecord adapter or if such feature could be supported in the future?

Process

  1. Create a new Rails project (Rails 5, ruby 2.5, mysql2 gem)
  2. Created a few DB models to test with using rails g model.
  3. Added trilogy gem to the gemfile and updated Gemlock bundle update.
  4. Updated adapter attribute in config/database.yml to be trilogy instead of mysql2.
  5. Ran rails c

Expected result

Running Rails c should work and I can run MyModelName.connection successfully.

Current result

Rails console fails to start

.rbenv/versions/2.5.8/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': Could not load the 'trilogy' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile. (LoadError)
@Kareem-Emad Kareem-Emad changed the title switching from mysql2 to `trilogy in Rails Switching from mysql2 to `trilogy in Rails Dec 17, 2021
@Kareem-Emad Kareem-Emad changed the title Switching from mysql2 to `trilogy in Rails Switching from mysql2 to trilogy in Rails Dec 17, 2021
@matthewd
Copy link
Contributor

Hi, and thanks for the interest!

We do indeed have an Active Record adapter that we'll soon be open-sourcing as a separate project -- we just had to get this low-level library out first. (But note it's likely to require Rails 7.0+ -- older Rails versions are progressively less likely to be supported.)

@dfuentes77
Copy link

Is this adapter out yet? Is this all a drop in replacement for mysql2? Does it require Rails7? I searched a bit and couldn't find anything obvious on any of this. Thanks!

@composerinteralia
Copy link
Contributor

composerinteralia commented Apr 21, 2022

The adapter is not out yet, but we are working on it. It currently only supports Rails 7.0+. Trilogy is also still missing some things, like support for prepared statements.

@antarr
Copy link

antarr commented Dec 19, 2023

I'm having the same problem on a Rails 7 project

@bensheldon
Copy link
Contributor

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

No branches or pull requests

6 participants