instance method replace_named_bind_variables

Ruby on Rails 6.1.7.10

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

replace_named_bind_variables(statement, bind_vars)

No documentation comment.

Parameters

statement req
bind_vars req
Source
# File activerecord/lib/active_record/sanitization.rb, line 170
        def replace_named_bind_variables(statement, bind_vars)
          statement.gsub(/(:?):([a-zA-Z]\w*)/) do |match|
            if $1 == ":" # skip postgresql casts
              match # return the whole match
            elsif bind_vars.include?(match = $2.to_sym)
              replace_bind_variable(bind_vars[match])
            else
              raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}"
            end
          end
        end

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

Defined in ActiveRecord::Sanitization::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close