aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/log_subscriber.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-27 13:42:02 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-27 16:10:03 -0700
commitb06f64c3480cd389d14618540d62da4978918af0 (patch)
tree626a163d2885fd3b91e58c6bcbf60ec3824a51f0 /activerecord/lib/active_record/log_subscriber.rb
parentd66ffb656e0cfbb4216f030c8e0669509567e362 (diff)
downloadrails-b06f64c3480cd389d14618540d62da4978918af0.tar.gz
rails-b06f64c3480cd389d14618540d62da4978918af0.tar.bz2
rails-b06f64c3480cd389d14618540d62da4978918af0.zip
Remove Relation#bind_params
`bound_attributes` is now used universally across the board, removing the need for the conversion layer. These changes are mostly mechanical, with the exception of the log subscriber. Additional, we had to implement `hash` on the attribute objects, so they could be used as a key for query caching.
Diffstat (limited to 'activerecord/lib/active_record/log_subscriber.rb')
-rw-r--r--activerecord/lib/active_record/log_subscriber.rb20
1 files changed, 7 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb
index a5c7279db9..6b26d7be78 100644
--- a/activerecord/lib/active_record/log_subscriber.rb
+++ b/activerecord/lib/active_record/log_subscriber.rb
@@ -20,18 +20,14 @@ module ActiveRecord
@odd = false
end
- def render_bind(column, value)
- if column
- if column.binary? && value
- # This specifically deals with the PG adapter that casts bytea columns into a Hash.
- value = value[:value] if value.is_a?(Hash)
- value = "<#{value.bytesize} bytes of binary data>"
- end
-
- [column.name, value]
+ def render_bind(attribute)
+ value = if attribute.type.binary? && attribute.value
+ "<#{attribute.value.bytesize} bytes of binary data>"
else
- [nil, value]
+ attribute.value_for_database
end
+
+ [attribute.name, value]
end
def sql(event)
@@ -47,9 +43,7 @@ module ActiveRecord
binds = nil
unless (payload[:binds] || []).empty?
- binds = " " + payload[:binds].map { |col,v|
- render_bind(col, v)
- }.inspect
+ binds = " " + payload[:binds].map { |attr| render_bind(attr) }.inspect
end
if odd?