From ccfe1d23a3317bd090d9dafccc72ec572918f80c Mon Sep 17 00:00:00 2001 From: Ryan Krage Date: Fri, 17 Nov 2023 21:50:44 +0000 Subject: [PATCH] remove inspect delegation in lock mode Co-authored-by: Ryan Krage --- lib/pg_ha_migrations/lock_mode.rb | 2 +- lib/pg_ha_migrations/safe_statements.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pg_ha_migrations/lock_mode.rb b/lib/pg_ha_migrations/lock_mode.rb index a4992e5..f1ba0a7 100644 --- a/lib/pg_ha_migrations/lock_mode.rb +++ b/lib/pg_ha_migrations/lock_mode.rb @@ -68,7 +68,7 @@ class LockMode attr_reader :mode - delegate :inspect, :to_s, to: :mode + delegate :to_s, to: :mode def initialize(mode) @mode = mode diff --git a/lib/pg_ha_migrations/safe_statements.rb b/lib/pg_ha_migrations/safe_statements.rb index f7116ce..73df8cf 100644 --- a/lib/pg_ha_migrations/safe_statements.rb +++ b/lib/pg_ha_migrations/safe_statements.rb @@ -530,7 +530,7 @@ def safely_acquire_lock_for_table(table, mode: :access_exclusive, &block) if nested_target_table != target_table raise PgHaMigrations::InvalidMigrationError, "Nested lock detected! Cannot acquire lock on #{target_table.fully_qualified_name} while #{nested_target_table.fully_qualified_name} is locked." elsif nested_target_table.mode < target_table.mode - raise PgHaMigrations::InvalidMigrationError, "Lock escalation detected! Cannot change lock level from #{nested_target_table.mode.inspect} to #{target_table.mode.inspect} for #{target_table.fully_qualified_name}." + raise PgHaMigrations::InvalidMigrationError, "Lock escalation detected! Cannot change lock level from :#{nested_target_table.mode} to :#{target_table.mode} for #{target_table.fully_qualified_name}." end else Thread.current[__method__] = target_table