module Sequel::Plugins::PreparedStatements::InstanceMethods

Private Instance Methods

_insert_raw(ds) click to toggle source

Use a prepared statement to insert the values into the model's dataset.

Calls superclass method
    # File lib/sequel/plugins/prepared_statements.rb
125 def _insert_raw(ds)
126   if use_prepared_statements_for?(:insert)
127     _set_prepared_statement_server(model.send(:prepared_insert, @values.keys)).call(@values)
128   else
129     super
130   end
131 end
_insert_select_raw(ds) click to toggle source

Use a prepared statement to insert the values into the model's dataset and return the new column values.

Calls superclass method
    # File lib/sequel/plugins/prepared_statements.rb
135 def _insert_select_raw(ds)
136   if use_prepared_statements_for?(:insert_select)
137     _set_prepared_statement_server(model.send(:prepared_insert_select, @values.keys)).call(@values)
138   else
139     super
140   end
141 end
_set_prepared_statement_server(ps) click to toggle source

If a server is set for the instance, return a prepared statement that will use that server.

    # File lib/sequel/plugins/prepared_statements.rb
153 def _set_prepared_statement_server(ps)
154   if @server
155     ps.server(@server)
156   else
157     ps
158   end
159 end
_update_without_checking(columns) click to toggle source

Use a prepared statement to update this model's columns in the database.

Calls superclass method
    # File lib/sequel/plugins/prepared_statements.rb
144 def _update_without_checking(columns)
145   if use_prepared_statements_for?(:update)
146     _set_prepared_statement_server(model.send(:prepared_update, columns.keys)).call(columns.merge(pk_hash))
147   else
148     super
149   end
150 end
use_prepared_statements_for?(type) click to toggle source

Whether prepared statements should be used for the given type of query (:insert, :insert_select, :update). True by default, can be overridden in other plugins to disallow prepared statements for specific types of queries.

Calls superclass method
    # File lib/sequel/plugins/prepared_statements.rb
165 def use_prepared_statements_for?(type)
166   if defined?(super)
167     result = super
168     return result unless result.nil?
169   end
170 
171   case type
172   when :insert, :insert_select, :update
173     true
174   # :nocov:
175   when :delete, :refresh
176     Sequel::Deprecation.deprecate("The :delete and :refresh prepared statement types", "There should be no need to check if these types are supported")
177     false
178   # :nocov:
179   else
180     raise Error, "unsupported type used: #{type.inspect}"
181   end
182 end