Sha256: cba3bfb07de0b57201c71858336df3b915a5e5a75e605a212ca19cfd84028a0d

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

module DirectiveRecord
  module Query
    class MySQL < SQL

    private

      def path_delimiter
        "."
      end

      def aggregate_delimiter
        ":"
      end

      def quote_alias(sql_alias)
        "`#{sql_alias}`"
      end

      def finalize_options!(options)
        return unless options[:numerize_aliases]

        aliases = options[:aliases] || {}

        [:group_by, :having, :order_by].each do |key|
          if value = options[key]
            value = value.join ", "
            aliases.each{|pattern, replacement| value.gsub! /(?=^|\b|\s)#{Regexp.escape pattern}(?=\b|\s|$)/, replacement}
            options[key] = value
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
directiverecord-0.1.32 lib/directive_record/query/mysql.rb
directiverecord-0.1.31 lib/directive_record/query/mysql.rb