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
variables = @config.fetch(:variables, {}).stringify_keys
unless variables["timezone"]
if ActiveRecord::Base.default_timezone == :utc
variables["timezone"] = "UTC"
elsif @local_tz
variables["timezone"] = @local_tz
end
end
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