Sha256: 87f625e5a5d930db9d7a32ebf191178937113f7c8a09d59f9d671d1319b9370f

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

# -*- encoding : utf-8 -*-
module ActiveRecord
  module QuotingAndMatching
    # dummy module to trigger loading code below
  end

  module ConnectionAdapters
    class AbstractAdapter
      def quote_interval(string)
        raise "quote_interval not implemented"
      end

      def match(string)
        raise "match not implemented"
      end

      def cast_types
        native_database_types.merge custom_cast_types
      end

      def custom_cast_types
        {}
      end
    end

    class PostgreSQLAdapter
      def quote_interval(string)
        "interval '#{string}'"
      end

      def match(string)
        "~* #{string}"
      end
    end

    module MysqlCommon
      def quote_interval(string)
        "interval #{string}"
      end

      def match(string)
        "REGEXP #{string}"
      end

      def custom_cast_types
        { :string  => { :name=>'char'    },
          :integer => { :name=>'signed'  },
          :text    => { :name=>'char'    },
          :float   => { :name=>'decimal' },
          :binary  => { :name=>'binary'  }  }
      end
    end

    class MysqlAdapter
      include MysqlCommon
    end

    class Mysql2Adapter
      include MysqlCommon
    end

    class SQLiteAdapter
      def quote_interval(string)
        "interval #{string}"
      end

      def match(string)
        "REGEXP #{string}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wagn-1.12.13 lib/active_record/quoting_and_matching.rb
wagn-1.12.12 lib/active_record/quoting_and_matching.rb
wagn-1.12.11 lib/active_record/quoting_and_matching.rb
wagn-1.12.10 lib/active_record/quoting_and_matching.rb
wagn-1.12.9 lib/active_record/quoting_and_matching.rb
wagn-1.12.8 lib/active_record/quoting_and_matching.rb
wagn-1.12.7 lib/active_record/quoting_and_matching.rb