Skip to content

Commit

Permalink
Fix: options not propagated in blocking activity logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hareau authored and ThHareau committed Dec 13, 2023
1 parent 679ed20 commit 315cc23
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/safe-pg-migrations/plugins/blocking_activity_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ module BlockingActivityLogger

RETRIABLE_SCHEMA_STATEMENTS.each do |method|
define_method method do |*args, **options, &block|
args, options = if args.last.is_a?(Hash)
[args[..-2], args.last]
else
[args, {}]
end
log_context = lambda do
break unless SafePgMigrations.config.sensitive_logger

Expand Down
15 changes: 15 additions & 0 deletions test/StatementInsurer/remove_column_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,20 @@ def change

assert_equal ['ALTER TABLE "users" DROP COLUMN "name"'], calls[2]
end

def test_remove_column_with_default_arguments
@connection.create_table(:users) { |t| t.string :name }

@migration =
Class.new(ActiveRecord::Migration::Current) do
def change
remove_column(:users, :name, :string, null: false, default: 'Benaaaa')
end
end.new

calls = record_calls(@connection, :execute) { run_migration }

assert_equal ['ALTER TABLE "users" DROP COLUMN "name"'], calls[2]
end
end
end

0 comments on commit 315cc23

Please sign in to comment.