Sha256: 255656ee7ae61266de4a32d5865ce565c2de5b310e41d27b657408bddb2f3fef

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

module ActiveRecord
  class Base
    def self.find_boolean(find_type, field, value=true, *options)
      self.find(find_type,
                :conditions => ["#{field} = ?", value], *options)
    end
  end

  # Horrible monkey patch 'til Rails fixes this
  module ConnectionAdapters
    class MysqlAdapter
      def change_column(table_name, column_name, type, options ={ }) #:nodoc:
        if options[:default].nil?
          options[:default] =
            select_one("SHOW COLUMNS FROM #{table_name} LIKE '#{column_name}'")["Default"]
        end
        change_column_sql = "ALTER TABLE #{table_name} CHANGE #{column_name} #{column_name} #{type_to_sql(type, options[:limit])}"
        add_column_options!(change_column_sql, options)
        execute(change_column_sql)
      end
    end

    class SqliteAdapter
      def change_column(table_name, column_name, type, options ={ }) #:nodoc:
        alter_table(table_name) do |definition|
          definition[column_name].instance_eval do
            self.type    = type
            self.limit   = options[:limit] if options[:limit]
            self.default = options[:default] unless options[:default].nil?
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
typo-3.99.0 lib/rails_patch/active_record.rb
typo-3.99.1 lib/rails_patch/active_record.rb
typo-3.99.3 lib/rails_patch/active_record.rb
typo-3.99.2 lib/rails_patch/active_record.rb
typo-4.0.1 lib/rails_patch/active_record.rb
typo-4.0.0 lib/rails_patch/active_record.rb
typo-4.0.2 lib/rails_patch/active_record.rb
typo-3.99.4 lib/rails_patch/active_record.rb
typo-4.0.3 lib/rails_patch/active_record.rb