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

Clean up shared DB statements code between Mysql2 and Trilogy #48112

Merged

Conversation

adrianna-chang-shopify
Copy link
Contributor

Motivation / Background

There is a lot of duplicated code between ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements (used by Mysql2Adapter) and ActiveRecord::ConnectionAdapters::Trilogy::DatabaseStatements. This PR introduces a DatabaseStatements module at the AbstractMysqlAdapter level, and moves this shared code into it.

Detail

This PR makes two changes:

  1. Renames the existing MySQL::DatabaseStatements module to Mysql2::DatabaseStatements, since it's Mysql2-specific rather than MySQL specific. I did this because I'd like to use MySQL::DatabaseStatements to hold shared database statement logic for all MySQL-compatible adapters.
  2. Moves shared logic out of the Trilogy + Mysql2 database statement modules and into a new ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements module. This involves removing some code that was in the TrilogyAdapter that ought to have lived in the Trilogy::DatabaseStatements module (e.g. multi-statement support).

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@adrianna-chang-shopify
Copy link
Contributor Author

There are test failures around explain options that I need to investigate 🤔

@eileencodes eileencodes merged commit 5947ec2 into rails:main May 3, 2023
9 checks passed
@eileencodes eileencodes deleted the ac-shared-mysql-db-statements branch May 3, 2023 16:52
lorint added a commit to lorint/activerecord-trilogy-adapter that referenced this pull request Jul 8, 2023
lorint added a commit to lorint/activerecord-trilogy-adapter that referenced this pull request Jul 9, 2023
lorint added a commit to lorint/activerecord-trilogy-adapter that referenced this pull request Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants