class method self.sanitize_sql_array

Ruby on Rails 3.1.12

Since v2.2.3 Last seen in v3.1.12

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12

Signature

self.sanitize_sql_array(ary)

Accepts an array of conditions. The array has each value sanitized and interpolated into the SQL statement.

["name='%s' and group_id='%s'", "foo'bar", 4]  returns  "name='foo''bar' and group_id='4'"

Parameters

ary req
Source
# File activerecord/lib/active_record/base.rb, line 1466
        def sanitize_sql_array(ary)
          statement, *values = ary
          if values.first.is_a?(Hash) && statement =~ /:\w+/
            replace_named_bind_variables(statement, values.first)
          elsif statement.include?('?')
            replace_bind_variables(statement, values)
          elsif statement.blank?
            statement
          else
            statement % values.collect { |value| connection.quote_string(value.to_s) }
          end
        end

Defined in activerecord/lib/active_record/base.rb line 1466 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close