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]
@raw_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]
unless ActiveRecord.db_warnings_action.nil?
@raw_connection.set_notice_receiver do |result|
message = result.error_field(PG::Result::PG_DIAG_MESSAGE_PRIMARY)
code = result.error_field(PG::Result::PG_DIAG_SQLSTATE)
level = result.error_field(PG::Result::PG_DIAG_SEVERITY)
@notice_receiver_sql_warnings << SQLWarning.new(message, code, level, nil, @pool)
end
end
set_standard_conforming_strings
variables = @config.fetch(:variables, {}).stringify_keys
internal_execute("SET intervalstyle = iso_8601")
variables.map do |k, v|
if v == ":default" || v == :default
internal_execute("SET SESSION #{k} TO DEFAULT")
elsif !v.nil?
internal_execute("SET SESSION #{k} TO #{quote(v)}")
end
end
add_pg_encoders
add_pg_decoders
reload_type_map
end