Skip to content

Commit

Permalink
Fix failing to detect encoding with JDBC MySQL adapter
Browse files Browse the repository at this point in the history
Also switching JRuby CI to use MySQL instead of SQLite, because of frequent '[SQLITE_BUSY]' error
  • Loading branch information
mshibuya committed Feb 6, 2022
1 parent 4297552 commit 0dfe2e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- ruby: jruby
gemfile: gemfiles/rails_6.1.gemfile
orm: active_record
adapter: sqlite3
adapter: mysql2
asset: sprockets
- ruby: jruby
gemfile: gemfiles/rails_6.1.gemfile
Expand Down
6 changes: 5 additions & 1 deletion lib/rails_admin/adapters/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def encoding
when 'postgresql'
::ActiveRecord::Base.connection.select_one("SELECT ''::text AS str;").values.first.encoding
when 'mysql2'
::ActiveRecord::Base.connection.raw_connection.encoding
if RUBY_ENGINE == 'jruby'
::ActiveRecord::Base.connection.select_one("SELECT '' AS str;").values.first.encoding
else
::ActiveRecord::Base.connection.raw_connection.encoding
end
when 'oracle_enhanced'
::ActiveRecord::Base.connection.select_one('SELECT dummy FROM DUAL').values.first.encoding
else
Expand Down
1 change: 0 additions & 1 deletion spec/rails_admin/abstract_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
end

it 'lists elements within outbound limits' do
pending('Due to the JRuby SQLite3 datetime boundary issue') if RUBY_ENGINE == 'jruby' && CI_ORM == :active_record
expect(@abstract_model.all(filters: {'datetime_field' => {'1' => {v: ['', '2012-01-02T00:00:00', '2012-01-03T23:59:59'], o: 'between'}}}).count).to eq(2)
expect(@abstract_model.all(filters: {'datetime_field' => {'1' => {v: ['', '2012-01-02T00:00:00', '2012-01-03T12:00:00'], o: 'between'}}}).count).to eq(1)
expect(@abstract_model.all(filters: {'datetime_field' => {'1' => {v: ['', '2012-01-03T12:00:00', ''], o: 'between'}}}).count).to eq(2)
Expand Down

0 comments on commit 0dfe2e4

Please sign in to comment.