Sha256: 61fda31923eb96742045c84effe42d78f7a77bc5f981a476424ade3093cdc47d

Contents?: true

Size: 842 Bytes

Versions: 15

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module QueryLogs
    class LegacyFormatter # :nodoc:
      def initialize
        @key_value_separator = ":"
      end

      # Formats the key value pairs into a string.
      def format(pairs)
        pairs.map! do |key, value|
          "#{key}#{key_value_separator}#{format_value(value)}"
        end.join(",")
      end

      private
        attr_reader :key_value_separator

        def format_value(value)
          value
        end
    end

    class SQLCommenter < LegacyFormatter # :nodoc:
      def initialize
        @key_value_separator = "="
      end

      def format(pairs)
        pairs.sort_by! { |pair| pair.first.to_s }
        super
      end

      private
        def format_value(value)
          "'#{ERB::Util.url_encode(value)}'"
        end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
activerecord-7.2.2.1 lib/active_record/query_logs_formatter.rb
activerecord-7.1.5.1 lib/active_record/query_logs_formatter.rb
activerecord-7.2.2 lib/active_record/query_logs_formatter.rb
activerecord-7.1.5 lib/active_record/query_logs_formatter.rb
activerecord-7.2.1.2 lib/active_record/query_logs_formatter.rb
activerecord-7.1.4.2 lib/active_record/query_logs_formatter.rb
activerecord-7.2.1.1 lib/active_record/query_logs_formatter.rb
activerecord-7.1.4.1 lib/active_record/query_logs_formatter.rb
activerecord-7.1.4 lib/active_record/query_logs_formatter.rb
activerecord-7.2.1 lib/active_record/query_logs_formatter.rb
activerecord-7.2.0 lib/active_record/query_logs_formatter.rb
activerecord-7.2.0.rc1 lib/active_record/query_logs_formatter.rb
activerecord-7.2.0.beta3 lib/active_record/query_logs_formatter.rb
activerecord-7.2.0.beta2 lib/active_record/query_logs_formatter.rb
activerecord-7.2.0.beta1 lib/active_record/query_logs_formatter.rb