Sha256: 8937462f72ca68b6c09690b88107b8e640abe55856bc4fd2f63b24a99d5ca945

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

# Reference: https://stackoverflow.com/questions/62570662/rails-4-ruby-2-7-1-schema-rb-shows-could-not-dump-table-because-of-following-f

return unless RUBY_VERSION >= '2.7' && ::Rails.version < '5'

module ActiveRecord
  module ConnectionAdapters
    module ColumnDumper
      def prepare_column_options(column, types) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
        spec = {}
        spec[:name]      = column.name.inspect
        spec[:type]      = column.type.to_s
        spec[:null]      = 'false' unless column.null

        limit = column.limit || types[column.type][:limit]
        spec[:limit]     = limit.inspect if limit
        spec[:precision] = column.precision.inspect if column.precision
        spec[:scale]     = column.scale.inspect if column.scale

        default = schema_default(column).dup if column.has_default?
        spec[:default] = default unless default.nil?

        spec
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.13.2 config/initializers/ruby_2_7_rails_4_column_dumper.rb
redmine_plugins_helper-0.13.1 config/initializers/ruby_2_7_rails_4_column_dumper.rb
redmine_plugins_helper-0.13.0 config/initializers/ruby_2_7_rails_4_column_dumper.rb
redmine_plugins_helper-0.12.2 config/initializers/ruby_2_7_rails_4_column_dumper.rb
redmine_plugins_helper-0.12.1 config/initializers/ruby_2_7_rails_4_column_dumper.rb