configure_connection()
private
Configures the encoding, verbosity, schema search path, and time zone of
the connection. This is called by #connect
and should not be called manually.
Show source
def configure_connection
if @config[:encoding]
@connection.set_client_encoding(@config[:encoding])
end
self.client_min_messages = @config[:min_messages] || 'warning'
self.schema_search_path = @config[:schema_search_path] || @config[:schema_order]
set_standard_conforming_strings
if ActiveRecord::Base.default_timezone == :utc
execute("SET time zone 'UTC'", 'SCHEMA')
elsif @local_tz
execute("SET time zone '#{@local_tz}'", 'SCHEMA')
end
variables = @config[:variables] || {}
variables.map do |k, v|
if v == ':default' || v == :default
execute("SET SESSION #{k} TO DEFAULT", 'SCHEMA')
elsif !v.nil?
execute("SET SESSION #{k} TO #{quote(v)}", 'SCHEMA')
end
end
end