Sha256: c6b125ecf09c935aa8abb17b1beaeccbc0b32e0d82e4e9351dc0f3e2d66058ff
Contents?: true
Size: 877 Bytes
Versions: 10
Compression:
Stored size: 877 Bytes
Contents
require 'active_record/sanitization' module ActiveRecord module Sanitization extend ActiveSupport::Concern module ClassMethods def sanitize_sql_hash_for_assignment(attrs) attrs.map do |attr, value| "#{connection.quote_column_name(attr)} = #{quote_bound_value(value, attr)}" end.join(', ') end def quote_bound_value(value, column = nil, c = connection) if column.present? && column != c record_column = self.columns.select {|col| col.name == column}.first c.quote(value, record_column) elsif value.respond_to?(:map) && !value.acts_like?(:string) if value.respond_to?(:empty?) && value.empty? c.quote(nil) else value.map { |v| c.quote(v) }.join(',') end else c.quote(value) end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems