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 Rails 6.1 and 7.0 (DNM -- for reference only) #20

Closed
wants to merge 14 commits into from

Commits on Dec 28, 2022

  1. Support Rails 5.2, 6.x, and 7.0

    Seeing the performance advantages of the Trilogy driver compared
    with mysql2 has motivated me to make it compatible with older Rails
    versions. I'm hoping it can become the MySQL driver of choice in
    the Rails community. After trying several approaches, have ended up
    with the solution you see in this PR.
    
    **ActiveRecord Trilogy Adapter** was originally written with a
    forward-thinking mind set -- one exclusive to Rails 7.1 and later.
    The older database adapter framework found in prior versions of
    Rails differs a fair bit from that found in 7.1, so there are
    some core differences to bridge in order to have Trilogy become
    compatible with prior Rails versions. This PR adds backwards
    compatibility in such a way that it does not interfere with the
    lean nature of how AR Trilogy has been architected -- it adds
    that compatibility layer via a series of patches all tucked away in
    a separate file. Inside that compatibility file,
    backwards_ar_compatibility.rb, checks are done to identify which
    newer methods are missing. They are selectively added back in, with
    the ultimate goal of establishing the broadest compatibility
    possible. Only those patches which are necessary for any given
    Rails version get applied, making it minimally invasive.
    
    This approach requires no changes to Trilogy itself, so it
    functions in exactly the same way as it always has done -- as if
    everything is just ActiveRecord 7.1+. As such newer Rails 7.1 apps
    are completely unaffected because for them none of that patching
    needs be applied.
    lorint committed Dec 28, 2022
    Configuration menu
    Copy the full SHA
    481111d View commit details
    Browse the repository at this point in the history
  2. Enable tests to run under Rails < 7.1

    You're likely familiar with how to set up and run the tests for
    this project -- after confirming that inside of `bin/setup` on the
    last line it shows the same path out to `mysql` as you see when
    running `which mysql` then to test against edge Rails here are the
    commands:
    ```
    bin/setup
    bundle exec rake
    ```
    And once you've done that, which configures the test database
    appropriately then thankfully it's pretty easy to re-bundle in
    order to then run the tests under an older version:
    ```
    rm Gemfile.lock
    RAILS_VERSION="~> 6.1" bundle
    RAILS_VERSION="~> 6.1" bundle exec rake
    ```
    lorint committed Dec 28, 2022
    Configuration menu
    Copy the full SHA
    59bec56 View commit details
    Browse the repository at this point in the history

Commits on Dec 31, 2022

  1. Configuration menu
    Copy the full SHA
    ca4fdf9 View commit details
    Browse the repository at this point in the history
  2. Add the Appraisal gem

    Appraisal makes it simple to run the Trilogy tests for an specific version of ActiveRecord:
    
      bundle exec appraisal rails-7.0 rake
    
    or to run against edge Rails:
    
      bundle exec appraisal rails-head rake
    lorint committed Dec 31, 2022
    Configuration menu
    Copy the full SHA
    e121ccb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    787e6d9 View commit details
    Browse the repository at this point in the history

Commits on Jan 4, 2023

  1. Configuration menu
    Copy the full SHA
    8672123 View commit details
    Browse the repository at this point in the history

Commits on Jan 6, 2023

  1. Configuration menu
    Copy the full SHA
    411301d View commit details
    Browse the repository at this point in the history
  2. Fix query_flags timezone test failures under AR 6.1

    Set QUERY_FLAGS_LOCAL_TIMEZONE properly which should allow these two to pass:
      #test_query_flags_for_timezone_can_be_set_to_local
      #test_query_flags_for_timezone_can_be_set_to_local_and_reset_to_utc
    lorint committed Jan 6, 2023
    Configuration menu
    Copy the full SHA
    9cc4a25 View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2023

  1. Configuration menu
    Copy the full SHA
    be7812e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bc22c89 View commit details
    Browse the repository at this point in the history

Commits on Jan 14, 2023

  1. Configuration menu
    Copy the full SHA
    533e425 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2023

  1. Compatibility for updated error classes in Trilogy driver from PR#15

    There is a new generic Trilogy::ClientError class established with
    this PR which is useful to provide full AR 7.0 support:
    trilogy-libraries/trilogy#15
    lorint committed Jan 16, 2023
    Configuration menu
    Copy the full SHA
    711a689 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2023

  1. Some good Rubocop love

    lorint committed Jan 24, 2023
    Configuration menu
    Copy the full SHA
    9f60801 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2023

  1. Configuration menu
    Copy the full SHA
    8674e31 View commit details
    Browse the repository at this point in the history