JRuby

jdbcderby adapter should ignore :limit for INTEGER

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Fedora Linux 9, Sun Java 1.6.0_06, JRuby trunk (rev 8935), DerbyDB 10.2.2.0
  • Number of attachments :
    0

Description

When giving a :limit => 4 option to an integer field in a migration, and running it agawinst a berdy database, the generated DDL is converted to a INTEGER(4) type. Derby does not support this and fails. The jdbcderby adapter should ignore the :limit option for integers.

Activity

Hide
Uwe Kubosch added a comment -

I have a fix:

Add the following section at the bottom of

lib/active_record/connection_adapters/derby_adapter.rb

module ActiveRecord
module ConnectionAdapters # :nodoc:
module SchemaStatements

  1. Ignore limit for INTEGER types since Derby/JavaDB does not understand this.
    def type_to_sql_with_suppress_integer_limit(type, limit = nil, precision = nil, scale = nil) #:nodoc:
    type_to_sql_without_suppress_integer_limit(type, type == :integer ? nil : limit, precision, scale)
    end
    alias_method_chain :type_to_sql, :suppress_integer_limit
    end
    end
    end
Show
Uwe Kubosch added a comment - I have a fix: Add the following section at the bottom of lib/active_record/connection_adapters/derby_adapter.rb module ActiveRecord module ConnectionAdapters # :nodoc: module SchemaStatements
  1. Ignore limit for INTEGER types since Derby/JavaDB does not understand this. def type_to_sql_with_suppress_integer_limit(type, limit = nil, precision = nil, scale = nil) #:nodoc: type_to_sql_without_suppress_integer_limit(type, type == :integer ? nil : limit, precision, scale) end alias_method_chain :type_to_sql, :suppress_integer_limit end end end
Hide
Uwe Kubosch added a comment -

module ActiveRecord
module ConnectionAdapters # :nodoc:
module SchemaStatements

  1. Ignore limit for INTEGER types since Derby/JavaDB does not understand this.
    def type_to_sql_with_suppress_integer_limit(type, limit = nil, precision = nil, scale = nil) #:nodoc:
    type_to_sql_without_suppress_integer_limit(type, type == :integer ? nil : limit, precision, scale)
    end
    alias_method_chain :type_to_sql, :suppress_integer_limit
    end
    end
    end
    <noformat}
Show
Uwe Kubosch added a comment -

module ActiveRecord module ConnectionAdapters # :nodoc: module SchemaStatements
  1. Ignore limit for INTEGER types since Derby/JavaDB does not understand this. def type_to_sql_with_suppress_integer_limit(type, limit = nil, precision = nil, scale = nil) #:nodoc: type_to_sql_without_suppress_integer_limit(type, type == :integer ? nil : limit, precision, scale) end alias_method_chain :type_to_sql, :suppress_integer_limit end end end <noformat}
Hide
Uwe Kubosch added a comment -

Sorry for the stupid formatting. Here we are:

module ActiveRecord
  module ConnectionAdapters # :nodoc:
    module SchemaStatements
      # Ignore limit for INTEGER types since Derby/JavaDB does not understand this.
      def type_to_sql_with_suppress_integer_limit(type, limit = nil, precision = nil, scale = nil) #:nodoc:
        type_to_sql_without_suppress_integer_limit(type, type == :integer ? nil : limit, precision, scale)
      end
      alias_method_chain :type_to_sql, :suppress_integer_limit
    end
  end
end
Show
Uwe Kubosch added a comment - Sorry for the stupid formatting. Here we are:
module ActiveRecord
  module ConnectionAdapters # :nodoc:
    module SchemaStatements
      # Ignore limit for INTEGER types since Derby/JavaDB does not understand this.
      def type_to_sql_with_suppress_integer_limit(type, limit = nil, precision = nil, scale = nil) #:nodoc:
        type_to_sql_without_suppress_integer_limit(type, type == :integer ? nil : limit, precision, scale)
      end
      alias_method_chain :type_to_sql, :suppress_integer_limit
    end
  end
end
Hide
Thomas E Enebo added a comment -

I fixed this the other day for derby. For posterity the logic:

    def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
      return super unless type == :integer

      native = native_database_types[type.to_s.downcase.to_sym]
      native.is_a?(Hash) ? native[:name] : native
    end
Show
Thomas E Enebo added a comment - I fixed this the other day for derby. For posterity the logic:
    def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
      return super unless type == :integer

      native = native_database_types[type.to_s.downcase.to_sym]
      native.is_a?(Hash) ? native[:name] : native
    end

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: