diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 0537077..f28d5a9 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -27,6 +27,7 @@ jobs: # See: https://github.community/t/mysql2-segmentation-fault-at-0x0000000000000000/159283 - 2.6 - 2.7 + - 3.0 gemfile: - 3.2.gemfile - 4.2.gemfile @@ -37,10 +38,20 @@ jobs: exclude: - gemfile: 3.2.gemfile ruby: 2.6 + - gemfile: 3.2.gemfile + ruby: 3.0 - gemfile: 3.2.gemfile ruby: 2.7 - gemfile: 4.2.gemfile ruby: 2.7 + - gemfile: 4.2.gemfile + ruby: 3.0 + - gemfile: 5.0.gemfile + ruby: 3.0 + - gemfile: 5.1.gemfile + ruby: 3.0 + - gemfile: 5.2.gemfile + ruby: 3.0 - gemfile: 6.0.gemfile ruby: 2.2 include: diff --git a/README.md b/README.md index 544995b..2fa2804 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ All methods are defined in `Atomically::QueryService` instead of defining in `ActiveRecord` directly, in order not to pollute the model instance. ## Supports -- Ruby 2.2 ~ 2.7 +- Ruby 2.2 ~ 2.7, 3.0 - Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0 - MySQL, PostgreSQL diff --git a/gemfiles/4.2.gemfile b/gemfiles/4.2.gemfile index 9c2fb09..60a797b 100644 --- a/gemfiles/4.2.gemfile +++ b/gemfiles/4.2.gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'activerecord', '~> 4.2.0' group :test do - gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB']) + gem 'mysql2', '0.4.10' if %w[mysql makara_mysql].include?(ENV['DB']) gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB']) gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB']) gem 'simplecov', '< 0.18' diff --git a/gemfiles/5.0.gemfile b/gemfiles/5.0.gemfile index 0b2ec97..1965941 100644 --- a/gemfiles/5.0.gemfile +++ b/gemfiles/5.0.gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'activerecord', '~> 5.0.0' group :test do - gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB']) + gem 'mysql2', '0.4.10' if %w[mysql makara_mysql].include?(ENV['DB']) gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB']) gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB']) gem 'simplecov', '< 0.18' diff --git a/gemfiles/5.1.gemfile b/gemfiles/5.1.gemfile index 3f47bb7..ebb10b6 100644 --- a/gemfiles/5.1.gemfile +++ b/gemfiles/5.1.gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'activerecord', '~> 5.1.0' group :test do - gem 'mysql2', '0.3.21' if %w[mysql makara_mysql].include?(ENV['DB']) + gem 'mysql2', '0.4.10' if %w[mysql makara_mysql].include?(ENV['DB']) gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB']) gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB']) gem 'simplecov', '< 0.18' diff --git a/gemfiles/6.0.gemfile b/gemfiles/6.0.gemfile index 3240d59..52cf387 100644 --- a/gemfiles/6.0.gemfile +++ b/gemfiles/6.0.gemfile @@ -4,7 +4,7 @@ gem 'activerecord', '~> 6.0.0' group :test do gem 'mysql2', '0.5.1' if %w[mysql makara_mysql].include?(ENV['DB']) - gem 'pg', '~> 0.18' if %w[pg makara_pg].include?(ENV['DB']) + gem 'pg', '~> 1.4.6' if %w[pg makara_pg].include?(ENV['DB']) gem 'makara', '~> 0.4.1' if %w[makara_mysql makara_pg].include?(ENV['DB']) gem 'simplecov', '< 0.18' gem 'pluck_all', '>= 2.0.4' diff --git a/lib/atomically/query_service.rb b/lib/atomically/query_service.rb index 972a751..e0cceb4 100644 --- a/lib/atomically/query_service.rb +++ b/lib/atomically/query_service.rb @@ -51,7 +51,8 @@ def update_all(expected_size, *args) where_all_can_be_updated(@relation, expected_size).update_all(*args) end - def update(attrs, from: :not_set) + def update(attrs, options = {}) + from = options[:from] || :not_set success = update_and_return_number_of_updated_rows(attrs, from) == 1 if success diff --git a/test/test_helper.rb b/test/test_helper.rb index 761f341..a43ca39 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -38,7 +38,10 @@ def in_sandbox def assert_queries(expected_count, event_key = 'sql.active_record') sqls = [] subscriber = ActiveSupport::Notifications.subscribe(event_key) do |_, _, _, _, payload| - sqls << " ● #{payload[:sql]}" if payload[:sql] !~ /\A(?:BEGIN TRANSACTION|COMMIT TRANSACTION|BEGIN|COMMIT)\z/i + next if payload[:sql].start_with?('PRAGMA table_info') + next if payload[:sql] =~ /\A(?:BEGIN TRANSACTION|COMMIT TRANSACTION|BEGIN|COMMIT)\z/i + + sqls << " ● #{payload[:sql]}" end yield if expected_count != sqls.size # show all sql queries if query count doesn't equal to expected count.