Commit 2be4b3d4 authored by Igor Drozdov's avatar Igor Drozdov

Fix Ruby 2.7 deprecated kwargs usages

In Rails 6.0 the method calls are flexible and accept either
hash or kwargs

In Rails 6.1 the support is removed
parent 06dd3bcf
...@@ -6,7 +6,7 @@ module ThrottledTouch ...@@ -6,7 +6,7 @@ module ThrottledTouch
# The amount of time to wait before "touch" can update a record again. # The amount of time to wait before "touch" can update a record again.
TOUCH_INTERVAL = 1.minute TOUCH_INTERVAL = 1.minute
def touch(*args) def touch(*args, **kwargs)
super if (Time.zone.now - updated_at) > TOUCH_INTERVAL super if (Time.zone.now - updated_at) > TOUCH_INTERVAL
end end
end end
...@@ -495,7 +495,7 @@ class Note < ApplicationRecord ...@@ -495,7 +495,7 @@ class Note < ApplicationRecord
noteable&.expire_note_etag_cache noteable&.expire_note_etag_cache
end end
def touch(*args) def touch(*args, **kwargs)
# We're not using an explicit transaction here because this would in all # We're not using an explicit transaction here because this would in all
# cases result in all future queries going to the primary, even if no writes # cases result in all future queries going to the primary, even if no writes
# are performed. # are performed.
......
...@@ -51,7 +51,7 @@ module Gitlab ...@@ -51,7 +51,7 @@ module Gitlab
allow_null: options[:null] allow_null: options[:null]
) )
else else
add_column(table_name, column_name, :datetime_with_timezone, options) add_column(table_name, column_name, :datetime_with_timezone, **options)
end end
end end
end end
...@@ -143,13 +143,13 @@ module Gitlab ...@@ -143,13 +143,13 @@ module Gitlab
options = options.merge({ algorithm: :concurrently }) options = options.merge({ algorithm: :concurrently })
if index_exists?(table_name, column_name, options) if index_exists?(table_name, column_name, **options)
Gitlab::AppLogger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" Gitlab::AppLogger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}"
return return
end end
disable_statement_timeout do disable_statement_timeout do
add_index(table_name, column_name, options) add_index(table_name, column_name, **options)
end end
end end
...@@ -169,13 +169,13 @@ module Gitlab ...@@ -169,13 +169,13 @@ module Gitlab
options = options.merge({ algorithm: :concurrently }) options = options.merge({ algorithm: :concurrently })
unless index_exists?(table_name, column_name, options) unless index_exists?(table_name, column_name, **options)
Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}"
return return
end end
disable_statement_timeout do disable_statement_timeout do
remove_index(table_name, options.merge({ column: column_name })) remove_index(table_name, **options.merge({ column: column_name }))
end end
end end
...@@ -205,7 +205,7 @@ module Gitlab ...@@ -205,7 +205,7 @@ module Gitlab
end end
disable_statement_timeout do disable_statement_timeout do
remove_index(table_name, options.merge({ name: index_name })) remove_index(table_name, **options.merge({ name: index_name }))
end end
end end
...@@ -1194,8 +1194,8 @@ module Gitlab ...@@ -1194,8 +1194,8 @@ module Gitlab
end end
end end
def remove_foreign_key_without_error(*args) def remove_foreign_key_without_error(*args, **kwargs)
remove_foreign_key(*args) remove_foreign_key(*args, **kwargs)
rescue ArgumentError rescue ArgumentError
end end
......
...@@ -40,7 +40,7 @@ module Gitlab ...@@ -40,7 +40,7 @@ module Gitlab
end end
with_lock_retries do with_lock_retries do
add_index(table_name, column_names, options) add_index(table_name, column_names, **options)
end end
end end
......
...@@ -64,7 +64,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::IndexHelpers do ...@@ -64,7 +64,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::IndexHelpers do
def expect_add_concurrent_index_and_call_original(table, column, index) def expect_add_concurrent_index_and_call_original(table, column, index)
expect(migration).to receive(:add_concurrent_index).ordered.with(table, column, name: index) expect(migration).to receive(:add_concurrent_index).ordered.with(table, column, name: index)
.and_wrap_original { |_, table, column, options| connection.add_index(table, column, options) } .and_wrap_original { |_, table, column, options| connection.add_index(table, column, **options) }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment