module Sequel::Plugins::PreparedStatementsSafe::ClassMethods
Attributes
A hash with column symbol keys and default values. Instance values are merged into this hash before creating to reduce the number of free columns (columns that may or may not be present in the INSERT statement), as the number of prepared statements that can be created is 2^N (where N is the number of free columns).
Public Instance Methods
Source
# File lib/sequel/plugins/prepared_statements_safe.rb 43 def freeze 44 @prepared_statements_column_defaults.freeze if @prepared_statements_column_defaults 45 46 super 47 end
Freeze the prepared statements column defaults when freezing the model class.
Calls superclass method
Private Instance Methods
Source
# File lib/sequel/plugins/prepared_statements_safe.rb 54 def set_prepared_statements_column_defaults 55 if db_schema 56 h = {} 57 db_schema.each do |k, v| 58 default = v[:ruby_default] 59 h[k] = default if (default || !v[:default]) && !v[:primary_key] && !default.is_a?(Sequel::SQL::Expression) 60 end 61 @prepared_statements_column_defaults = h 62 end 63 end
Set the column defaults based on the database schema. All columns are set to a default value unless they are a primary key column or they don’t have a parseable default.