From d0a0a42bf2e60f1d04a44af5f185da553b750519 Mon Sep 17 00:00:00 2001 From: Jordan Owens Date: Thu, 22 Aug 2024 20:19:54 -0400 Subject: [PATCH] Add support for ActiveRecord 7.2 --- .github/workflows/test.yaml | 14 +++++--------- gemfiles/7.2.gemfile | 3 +++ lib/activerecord-import/import.rb | 1 + test/models/topic.rb | 2 +- test/models/widget.rb | 13 ++++++++++--- 5 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 gemfiles/7.2.gemfile diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0b601351..f218532f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,6 +36,8 @@ jobs: ruby: - 3.3 env: + - AR_VERSION: '7.2' + RUBYOPT: --enable-frozen-string-literal - AR_VERSION: '7.1' RUBYOPT: --enable-frozen-string-literal - AR_VERSION: '7.0' @@ -43,6 +45,9 @@ jobs: - AR_VERSION: 6.1 RUBYOPT: --enable-frozen-string-literal include: + - ruby: 3.2 + env: + AR_VERSION: '7.2' - ruby: 3.2 env: AR_VERSION: '7.1' @@ -85,15 +90,6 @@ jobs: - ruby: 2.6 env: AR_VERSION: 5.2 - - ruby: 2.6 - env: - AR_VERSION: 5.1 - - ruby: 2.4 - env: - AR_VERSION: '5.0' - - ruby: 2.4 - env: - AR_VERSION: 4.2 runs-on: ubuntu-latest env: AR_VERSION: ${{ matrix.env.AR_VERSION }} diff --git a/gemfiles/7.2.gemfile b/gemfiles/7.2.gemfile new file mode 100644 index 00000000..5db01acf --- /dev/null +++ b/gemfiles/7.2.gemfile @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +gem 'activerecord', '~> 7.2.0' diff --git a/lib/activerecord-import/import.rb b/lib/activerecord-import/import.rb index 717fee4a..ca1ba6ad 100644 --- a/lib/activerecord-import/import.rb +++ b/lib/activerecord-import/import.rb @@ -62,6 +62,7 @@ def init_validations(klass) if @validate_callbacks.respond_to?(:chain, true) @validate_callbacks.send(:chain).tap do |chain| callback.instance_variable_set(:@filter, filter) + callback.instance_variable_set(:@compiled, nil) chain[i] = callback end else diff --git a/test/models/topic.rb b/test/models/topic.rb index dda46fab..3a12234f 100644 --- a/test/models/topic.rb +++ b/test/models/topic.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Topic < ActiveRecord::Base - if ENV['AR_VERSION'].to_i >= 6.0 + if ENV['AR_VERSION'].to_f >= 6.0 self.ignored_columns = [:priority] end alias_attribute :name, :title diff --git a/test/models/widget.rb b/test/models/widget.rb index 898beabc..0724e31b 100644 --- a/test/models/widget.rb +++ b/test/models/widget.rb @@ -19,8 +19,15 @@ class Widget < ActiveRecord::Base default_scope -> { where(active: true) } - serialize :data, Hash - serialize :json_data, JSON + if ENV['AR_VERSION'].to_f >= 7.1 + serialize :data, coder: YAML + serialize :json_data, coder: JSON + serialize :custom_data, coder: CustomCoder.new + else + serialize :data, Hash + serialize :json_data, JSON + serialize :custom_data, CustomCoder.new + end + serialize :unspecified_data - serialize :custom_data, CustomCoder.new end