From 05167d8bd45afd23e2ef0d43fff8af0ee2f038f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Thu, 30 Nov 2023 19:21:25 +0100 Subject: [PATCH] test: add 7.1 to test matrix --- .github/workflows/acceptance-tests-on-emulator.yaml | 2 +- .github/workflows/ci.yaml | 2 +- .../workflows/nightly-acceptance-tests-on-emulator.yaml | 2 +- .github/workflows/nightly-unit-tests.yaml | 2 +- acceptance/test_helper.rb | 4 +--- lib/activerecord_spanner_adapter/base.rb | 8 +++++++- .../interleaved_tables_test.rb | 2 +- .../model_helper.rb | 4 +--- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/acceptance-tests-on-emulator.yaml b/.github/workflows/acceptance-tests-on-emulator.yaml index b36529f4..fc3f446f 100644 --- a/.github/workflows/acceptance-tests-on-emulator.yaml +++ b/.github/workflows/acceptance-tests-on-emulator.yaml @@ -19,7 +19,7 @@ jobs: max-parallel: 4 matrix: ruby: ["2.7", "3.0", "3.1", "3.2"] - ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4"] + ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4", "~> 7.1.0"] # Exclude combinations that are not supported. exclude: - ruby: "3.0" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e710b9d4..01013ccc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: max-parallel: 4 matrix: ruby: ["2.7", "3.0", "3.1", "3.2"] - ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4"] + ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4", "~> 7.1.0"] # Exclude combinations that are not supported. exclude: - ruby: "3.0" diff --git a/.github/workflows/nightly-acceptance-tests-on-emulator.yaml b/.github/workflows/nightly-acceptance-tests-on-emulator.yaml index e288fcea..9e308dd8 100644 --- a/.github/workflows/nightly-acceptance-tests-on-emulator.yaml +++ b/.github/workflows/nightly-acceptance-tests-on-emulator.yaml @@ -20,7 +20,7 @@ jobs: matrix: # Run acceptance tests all supported combinations of Ruby and ActiveRecord. ruby: [2.7, 3.0, 3.1, 3.2] - ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.3.2, 6.1.4.7, 6.1.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1, 7.0.4, 7.0.5, 7.0.6, 7.0.7] + ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.3.2, 6.1.4.7, 6.1.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1, 7.0.4, 7.0.5, 7.0.6, 7.0.7, 7.1.0, 7.1.1, 7.1.2] # Exclude combinations that are not supported. exclude: - ruby: 3.0 diff --git a/.github/workflows/nightly-unit-tests.yaml b/.github/workflows/nightly-unit-tests.yaml index f18aa007..e64bc765 100644 --- a/.github/workflows/nightly-unit-tests.yaml +++ b/.github/workflows/nightly-unit-tests.yaml @@ -12,7 +12,7 @@ jobs: matrix: # Run unit tests all supported combinations of Ruby and ActiveRecord. ruby: [2.7, 3.0, 3.1, 3.2] - ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.3.2, 6.1.4.7, 6.1.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1, 7.0.4, 7.0.5] + ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.3.2, 6.1.4.7, 6.1.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1, 7.0.4, 7.0.5, 7.1.0, 7.1.1, 7.1.2] # Exclude combinations that are not supported. exclude: - ruby: 3.0 diff --git a/acceptance/test_helper.rb b/acceptance/test_helper.rb index 93a61821..31fee199 100644 --- a/acceptance/test_helper.rb +++ b/acceptance/test_helper.rb @@ -4,8 +4,6 @@ # license that can be found in the LICENSE file or at # https://opensource.org/licenses/MIT. -VERSION_7_1_0 = Gem::Version.create('7.1.0') - gem "minitest" require "minitest/autorun" require "minitest/focus" @@ -17,7 +15,7 @@ require "activerecord-spanner-adapter" require "active_record/connection_adapters/spanner_adapter" require "securerandom" -require "composite_primary_keys" if ActiveRecord::gem_version < VERSION_7_1_0 +require "composite_primary_keys" if ActiveRecord::gem_version < Gem::Version.create('7.1.0') # rubocop:disable Style/GlobalVars diff --git a/lib/activerecord_spanner_adapter/base.rb b/lib/activerecord_spanner_adapter/base.rb index 91d595eb..08b8eab2 100644 --- a/lib/activerecord_spanner_adapter/base.rb +++ b/lib/activerecord_spanner_adapter/base.rb @@ -14,6 +14,8 @@ class TableMetadata # :nodoc: end class Base + VERSION_7_1 = Gem::Version.create('7.1.0') + # Creates an object (or multiple objects) and saves it to the database. This method will use mutations instead # of DML if there is no active transaction, or if the active transaction has been created with the option # isolation: :buffered_mutations. @@ -60,7 +62,10 @@ def self._insert_record values, returning = [] else im = arel_table.compile_insert _substitute_values(values) end - [connection.insert(im, "#{self} Create", primary_key || false, primary_key_value)] + result = connection.insert(im, "#{self} Create", primary_key || false, primary_key_value) + + return result if ActiveRecord::gem_version < VERSION_7_1 + [result] end def self._upsert_record values @@ -135,6 +140,7 @@ def self._buffer_record values, method connection.current_spanner_transaction.buffer mutation + return primary_key_value if ActiveRecord::gem_version < VERSION_7_1 [primary_key_value] end diff --git a/test/activerecord_spanner_interleaved_table/interleaved_tables_test.rb b/test/activerecord_spanner_interleaved_table/interleaved_tables_test.rb index ff52491a..aa5f4886 100644 --- a/test/activerecord_spanner_interleaved_table/interleaved_tables_test.rb +++ b/test/activerecord_spanner_interleaved_table/interleaved_tables_test.rb @@ -10,7 +10,7 @@ require_relative "../mock_server/spanner_mock_server" require_relative "../test_helper" -return if ActiveRecord::gem_version >= VERSION_7_1_0 +return if ActiveRecord::gem_version >= Gem::Version.create('7.1.0') require_relative "models/singer" require_relative "models/album" diff --git a/test/activerecord_spanner_interleaved_table/model_helper.rb b/test/activerecord_spanner_interleaved_table/model_helper.rb index 86d1c249..30e7bac6 100644 --- a/test/activerecord_spanner_interleaved_table/model_helper.rb +++ b/test/activerecord_spanner_interleaved_table/model_helper.rb @@ -6,12 +6,10 @@ # # frozen_string_literal: true -VERSION_7_1_0 = Gem::Version.create('7.1.0') - require_relative "../mock_server/spanner_mock_server" require_relative "../test_helper" -return if ActiveRecord::gem_version >= VERSION_7_1_0 +return if ActiveRecord::gem_version >= Gem::Version.create('7.1.0') require_relative "models/singer" require_relative "models/album"