lib/active_record/connection_adapters/cockroachdb_adapter.rb
# Configures the encoding, verbosity, schema search path, and time zone of the connection.
# This is called by #connect and should not be called manually.
#
# NOTE(joey): This was cradled from postgresql_adapter.rb. This
# was due to needing to override configuration statements.
Configures the encoding, verbosity, schema search path, and time zone of the connection.
This is called by #connect and should not be called manually.

This was cradled from postgresql_adapter.rb. This
was due to needing to override configuration statements.
Configures the encoding verbosity schema search path and time zone of the connection . This is called by #connect and should not be called manually . This was cradled from postgresql_adapter . rb . This was due to needing to override configuration statements .
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
          if variables.key?("timezone")
            tz = variables.delete("timezone")
            execute("SET TIME ZONE #{quote(tz)}", "SCHEMA")
          end
          variables.map do |k, v|
            if v == ":default" || v == :default
            elsif !v.nil?
              execute("SET SESSION #{k} = #{quote(v)}", "SCHEMA")
            end
          end
        end
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 if variables . key? ( "timezone" ) tz = variables . delete ( "timezone" ) execute ( "SET TIME ZONE #{quote(tz)}" , "SCHEMA" ) end variables . map do | k , v | if v == ":default" || v == :default elsif ! v . nil? execute ( "SET SESSION #{k} = #{quote(v)}" , "SCHEMA" ) end end end
Configures the encoding, verbosity, schema search path, and time zone of the connection.
Configures the encoding verbosity schema search path and time zone of the connection .
# Use standard-conforming strings so we don't have to do the E'...' dance. # If using Active Record's time zone support configure the connection to return # TIMESTAMP WITH ZONE types in UTC. # NOTE(joey): This is a workaround as CockroachDB 1.1.x # supports SET TIME ZONE <...> and SET "time zone" = <...> but # not SET timezone = <...>. # SET statements from :variables config hash # https://www.postgresql.org/docs/current/static/sql-set.html # Sets the value to the global or compile default # NOTE(joey): I am not sure if simply commenting this out # is technically correct. # execute("SET #{k} = DEFAULT", "SCHEMA")