Skip to content

Commit c376023

Browse files
handle nil value fo start_date in format_start_time
1 parent 70a17d4 commit c376023

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/safe-pg-migrations/helpers/blocking_activity_formatter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def output_confidentially_blocking_queries(queries)
4141
queries.each do |start_time, locktype, mode, pid, transactionid|
4242
Logger.say <<~MESSAGE.squish, sub_item: true, sensitive: true
4343
Query with pid #{pid || 'null'}
44-
started #{start_time ? format_start_time(start_time) : 'unknown'}:
44+
started #{format_start_time(start_time)}:
4545
lock type: #{locktype || 'null'},
4646
lock mode: #{mode || 'null'},
4747
lock transactionid: #{transactionid || 'null'}",
@@ -50,6 +50,8 @@ def output_confidentially_blocking_queries(queries)
5050
end
5151

5252
def format_start_time(start_time, reference_time = Time.now)
53+
return '(unknown start time)' unless start_time
54+
5355
start_time = Time.parse(start_time) unless start_time.is_a? Time
5456

5557
duration = (reference_time - start_time).round

0 commit comments

Comments
 (0)