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, line 128 def _insert_raw(ds) if use_prepared_statements_for?(:insert) _set_prepared_statement_server(model.send(:prepared_insert, @values.keys)).call(@values) else super end 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, line 138 def _insert_select_raw(ds) if use_prepared_statements_for?(:insert_select) if ps = model.send(:prepared_insert_select, @values.keys) _set_prepared_statement_server(ps).call(@values) end else super end 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, line 158 def _set_prepared_statement_server(ps) if @server ps.server(@server) else ps end 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, line 149 def _update_without_checking(columns) if use_prepared_statements_for?(:update) _set_prepared_statement_server(model.send(:prepared_update, columns.keys)).call(Hash[columns].merge!(pk_hash)) else super end 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, line 170 def use_prepared_statements_for?(type) if defined?(super) result = super return result unless result.nil? end case type when :insert, :insert_select, :update true # :nocov: when :delete, :refresh Sequel::Deprecation.deprecate("The :delete and :refresh prepared statement types", "There should be no need to check if these types are supported") false # :nocov: else raise Error, "unsupported type used: #{type.inspect}" end end