Skip to content

Commit

Permalink
Merge pull request #36350 from kamipo/fast_pluck
Browse files Browse the repository at this point in the history
Allow symbol (i.e. quoted identifier) as safe SQL string
  • Loading branch information
kamipo committed May 28, 2019
1 parent b064a78 commit c495fff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions activerecord/lib/active_record/attribute_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@ def attribute_names
/ix

def disallow_raw_sql!(args, permit: COLUMN_NAME) # :nodoc:
unexpected = args.reject do |arg|
Arel.arel_node?(arg) ||
unexpected = nil
args.each do |arg|
next if arg.is_a?(Symbol) || Arel.arel_node?(arg) ||
arg.to_s.split(/\s*,\s*/).all? { |part| permit.match?(part) }
(unexpected ||= []) << arg
end

return if unexpected.none?
return unless unexpected

if allow_unsafe_raw_sql == :deprecated
ActiveSupport::Deprecation.warn(
Expand Down

0 comments on commit c495fff

Please sign in to comment.