module Sequel::Plugins::PreparedStatements::InstanceMethods
Private Instance Methods
Source
# File lib/sequel/plugins/prepared_statements.rb 126 def _insert_raw(ds) 127 if use_prepared_statements_for?(:insert) 128 _set_prepared_statement_server(model.send(:prepared_insert, @values.keys)).call(@values) 129 else 130 super 131 end 132 end
Use a prepared statement to insert the values into the model’s dataset.
Calls superclass method
Source
# File lib/sequel/plugins/prepared_statements.rb 136 def _insert_select_raw(ds) 137 if use_prepared_statements_for?(:insert_select) 138 _set_prepared_statement_server(model.send(:prepared_insert_select, @values.keys)).call(@values) 139 else 140 super 141 end 142 end
Use a prepared statement to insert the values into the model’s dataset and return the new column values.
Calls superclass method
Source
# File lib/sequel/plugins/prepared_statements.rb 154 def _set_prepared_statement_server(ps) 155 if @server 156 ps.server(@server) 157 else 158 ps 159 end 160 end
If a server is set for the instance, return a prepared statement that will use that server.
Source
# File lib/sequel/plugins/prepared_statements.rb 145 def _update_without_checking(columns) 146 if use_prepared_statements_for?(:update) 147 _set_prepared_statement_server(model.send(:prepared_update, columns.keys)).call(columns.merge(pk_hash)) 148 else 149 super 150 end 151 end
Use a prepared statement to update this model’s columns in the database.
Calls superclass method
Source
# File lib/sequel/plugins/prepared_statements.rb 166 def use_prepared_statements_for?(type) 167 if defined?(super) 168 result = super 169 return result unless result.nil? 170 end 171 172 case type 173 when :insert, :update 174 true 175 when :insert_select 176 # SQLite RETURNING support has a bug that doesn't allow for committing transactions 177 # when a prepared statement with RETURNING has been used on the connection: 178 # 179 # SQLite3::BusyException: cannot commit transaction - SQL statements in progress: COMMIT 180 # 181 # Disabling usage of prepared statements for insert_select on SQLite seems to be the 182 # simplest way to workaround the problem. 183 db.database_type != :sqlite 184 # :nocov: 185 when :delete, :refresh 186 Sequel::Deprecation.deprecate("The :delete and :refresh prepared statement types", "There should be no need to check if these types are supported") 187 false 188 # :nocov: 189 else 190 raise Error, "unsupported type used: #{type.inspect}" 191 end 192 end
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