Skip to content

Commit

Permalink
chore: fix rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Dec 1, 2023
1 parent f3a38ee commit f8fa852
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/activerecord_spanner_adapter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

require "active_record/gem_version"
require "activerecord_spanner_adapter/relation"

module ActiveRecord
Expand All @@ -14,7 +15,7 @@ class TableMetadata # :nodoc:
end

class Base
VERSION_7_1 = Gem::Version.create('7.1.0')
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
Expand Down Expand Up @@ -64,8 +65,12 @@ def self._insert_record values, returning = []
end
result = connection.insert(im, "#{self} Create", primary_key || false, primary_key_value)

return result if ActiveRecord::gem_version < VERSION_7_1
[result]
_convert_primary_key result
end

def self._convert_primary_key primary_key_value
return primary_key_value if ActiveRecord.gem_version < VERSION_7_1
[primary_key_value]
end

def self._upsert_record values
Expand Down Expand Up @@ -137,11 +142,9 @@ def self._buffer_record values, method
mutation = Google::Cloud::Spanner::V1::Mutation.new(
"#{method}": write
)

connection.current_spanner_transaction.buffer mutation

return primary_key_value if ActiveRecord::gem_version < VERSION_7_1
[primary_key_value]
_convert_primary_key primary_key_value
end

def self._set_composite_primary_key_values primary_key, values
Expand Down

0 comments on commit f8fa852

Please sign in to comment.