Sha256: 6d9a68e4eccd91bed22b3793a6db43135ff1c8e5936b14c106c6af19fa8f88d4
Contents?: true
Size: 755 Bytes
Versions: 10
Compression:
Stored size: 755 Bytes
Contents
module Inquery module Mixins module RawSqlUtils extend ActiveSupport::Concern included do # Sanitizes the SQL and substitutes in the supplied variables. Relies on # `sanitize_sql_array` from ActiveRecord. def san(sql, *variables) ActiveRecord::Base.send(:sanitize_sql_array, [sql, *variables]) end # Executes the sql on the connection provided by calling `connection`, # which means that the method needs to be defined where this mixin is # included. The sql passed in should be sanitized. # Returns an instance of `ActiveRecord::Result`. def exec_query(sql) connection.exec_query(sql, self.class.to_s) end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems