Skip to content

Commit 659177c

Browse files
committed
Fix undefined method value_for_database in log
Could not log "sql.active_record" event. NoMethodError: undefined method `value_for_database' for
1 parent 413b59d commit 659177c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/arjdbc/abstract/core.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@ def translate_exception(exception, message:, sql:, binds:)
6060
# this version of log() automatically fills type_casted_binds from binds if necessary
6161
def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil, async: false)
6262
if binds.any? && (type_casted_binds.nil? || type_casted_binds.empty?)
63-
type_casted_binds = ->{ binds.map(&:value_for_database) } # extract_raw_bind_values
63+
type_casted_binds = lambda {
64+
# extract_raw_bind_values
65+
binds.map do |bind|
66+
if bind.respond_to?(:value_for_database)
67+
bind.value_for_database
68+
else
69+
bind
70+
end
71+
end
72+
}
6473
end
6574
super
6675
end

0 commit comments

Comments
 (0)