module Sequel::Plugins::PreparedStatements::InstanceMethods
Private Instance Methods
_delete_without_checking()
click to toggle source
Use a prepared statement to delete the row.
Calls superclass method
# File lib/sequel/plugins/prepared_statements.rb, line 157 def _delete_without_checking # SEQUEL5: Remove if use_prepared_statements_for?(:delete) _set_prepared_statement_server(model.send(:prepared_delete)).call(pk_hash) else super end end
_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 167 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 177 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
_refresh_get(ds)
click to toggle source
Use a prepared statement to refresh this model's column values.
Calls superclass method
# File lib/sequel/plugins/prepared_statements.rb, line 188 def _refresh_get(ds) # SEQUEL5: Remove if use_prepared_statements_for?(:refresh) _set_prepared_statement_server(model.send(:prepared_refresh)).call(pk_hash) 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 207 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 198 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, :refresh, :update, or :delete). 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 219 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 when :delete return true unless model.fast_instance_delete_sql # Using deletes for prepared statements appears faster on Oracle and DB2, # but not for most other database types if optimized SQL is used. db_type = model.db.database_type db_type == :oracle || db_type == :db2 when :refresh !model.fast_pk_lookup_sql else raise Error, "unsupported type used: #{type.inspect}" end end