Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

activerecord-jdbcmysql-adapter causing error for truncation

未关闭
#25 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
mysql, postgresql, rails, ruby

调研方向

使用 Gemfile 中的全部三个 JDBC 适配器,从 Rails 控制台复现 truncation 失败,然后检查 database_cleaner-1.0.1/lib/database_cleaner/active_record/truncation.rb 第 176 行和第 209 行附近的代码。移除 mysql JDBC 适配器后,比较适配器的加载行为;当 truncation 能够正常工作且受支持的适配器仍保持打包时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

We have an application that needs to support multiple database engines, so our Gemfile contains multiple JDBC adapters as so:

gem 'activerecord-jdbcpostgresql-adapter', '~>1.3.7'
gem 'activerecord-jdbcmssql-adapter', '~>1.3.7'
gem 'activerecord-jdbcmysql-adapter', '~>1.3.7'

The app works as we expect, and each setup with a different database works well, however we've just introduced the mysql adapter, and have now found that the database cleaner is failing to truncate the database.

On my machine, I have a postgres database running. If I open up a rails console, and attempt to clean the database with :truncation I get the following error

TypeError: superclass mismatch for class Mysql2Adapter

We haven't changed any code in our app, and if I comment out the mysql JDBC adapter from the Gemfile and bundle install again, I am once again able to clean the database.

This is the stack trace that I get with the error

from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/active_record/truncation.rb:209:in `ConnectionAdapters'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/active_record/truncation.rb:176:in `ActiveRecord'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/active_record/truncation.rb:175:in `(root)'
from org/jruby/RubyKernel.java:1065:in `require'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/base.rb:1:in `(root)'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/base.rb:108:in `orm_strategy'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/base.rb:34:in `create_strategy'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/base.rb:38:in `clean_with'
from org/jruby/RubyArray.java:1613:in `each'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/configuration.rb:85:in `clean_with'
from /Users/adrianh/.rvm/gems/jruby-1.7.12/gems/database_cleaner-1.0.1/lib/database_cleaner/configuration.rb:85:in `clean_with'

It's very similar (exact same error message) to other issues I've found here, however the line numbers are different so I'm assuming the issue is something different, given that the others have also been resolved and this is still appearing.

主要语言
Ruby
星标
76
派生
76
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DatabaseCleaner/database_cleaner-active_record 的其他 Issue

查看 DatabaseCleaner/database_cleaner-active_record 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。