Methods

Included Modules

Constants

ADAPTER_NAME = "Trilogy"
ER_ACCESS_DENIED_ERROR = 1045
ER_BAD_DB_ERROR = 1049
ER_DBACCESS_DENIED_ERROR = 1044
ER_SERVER_SHUTDOWN = 1053
SSL_MODES = { SSL_MODE_DISABLED: ::Trilogy::SSL_DISABLED, SSL_MODE_PREFERRED: ::Trilogy::SSL_PREFERRED_NOVERIFY, SSL_MODE_REQUIRED: ::Trilogy::SSL_REQUIRED_NOVERIFY, SSL_MODE_VERIFY_CA: ::Trilogy::SSL_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY: ::Trilogy::SSL_VERIFY_IDENTITY }.freeze
TYPE_MAP = Type::TypeMap.new.tap { |m| initialize_type_map(m) }

Class Public methods

new(...)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 102
      def initialize(...)
        super

        # Trilogy ignore `socket` if `host is set. We want the opposite to allow
        # configuring UNIX domain sockets via `DATABASE_URL`.
        @config.delete(:host) if @config[:socket]
      end
🔎 See on GitHub

new_client(config)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 57
        def new_client(config)
          config[:ssl_mode] = parse_ssl_mode(config[:ssl_mode]) if config[:ssl_mode]
          ::Trilogy.new(config)
        rescue ::Trilogy::Error => error
          raise translate_connect_error(config, error)
        end
🔎 See on GitHub

parse_ssl_mode(mode)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 64
        def parse_ssl_mode(mode)
          return mode if mode.is_a? Integer

          m = mode.to_s.upcase
          m = "SSL_MODE_#{m}" unless m.start_with? "SSL_MODE_"

          SSL_MODES.fetch(m.to_sym, mode)
        end
🔎 See on GitHub

translate_connect_error(config, error)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 73
        def translate_connect_error(config, error)
          case error.error_code
          when ER_DBACCESS_DENIED_ERROR, ER_BAD_DB_ERROR
            ActiveRecord::NoDatabaseError.db_error(config[:database])
          when ER_ACCESS_DENIED_ERROR
            ActiveRecord::DatabaseConnectionError.username_error(config[:username])
          else
            if error.message.include?("TRILOGY_DNS_ERROR")
              ActiveRecord::DatabaseConnectionError.hostname_error(config[:host])
            else
              ActiveRecord::ConnectionNotEstablished.new(error.message)
            end
          end
        end
🔎 See on GitHub

Instance Public methods

active?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 142
      def active?
        connection&.ping || false
      rescue ::Trilogy::Error
        false
      end
🔎 See on GitHub

discard!()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 158
      def discard!
        super
        unless connection.nil?
          connection.discard!
          self.connection = nil
        end
      end
🔎 See on GitHub

disconnect!()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 150
      def disconnect!
        super
        unless connection.nil?
          connection.close
          self.connection = nil
        end
      end
🔎 See on GitHub

quote_string(string)

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 136
      def quote_string(string)
        with_raw_connection(allow_retry: true, materialize_transactions: false) do |conn|
          conn.escape(string)
        end
      end
🔎 See on GitHub

savepoint_errors_invalidate_transactions?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 128
      def savepoint_errors_invalidate_transactions?
        true
      end
🔎 See on GitHub

supports_comments?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 116
      def supports_comments?
        true
      end
🔎 See on GitHub

supports_comments_in_create?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 120
      def supports_comments_in_create?
        true
      end
🔎 See on GitHub

supports_json?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 112
      def supports_json?
        !mariadb? && database_version >= "5.7.8"
      end
🔎 See on GitHub

supports_lazy_transactions?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 132
      def supports_lazy_transactions?
        true
      end
🔎 See on GitHub

supports_savepoints?()

📝 Source code
# File activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb, line 124
      def supports_savepoints?
        true
      end
🔎 See on GitHub