Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5464 (new defect)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Schema dumper doesn't handle native types correctly

Reported by: mail@matthewpainter.co.uk Assigned to: David
Priority: normal Milestone:
Component: ActiveRecord Version:
Severity: normal Keywords: schema dumper
Cc: bitsweat

Description

Schema dumper doesn't handle native types correctly. A (very) small (simple) patch below fixes the problem.

      def table(table, stream)

  ...

          columns.each do |column|
            #raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil?
            next if column.name == pk
            tbl.print "    t.column #{column.name.inspect}, "
            tbl.print @types[column.type].nil? ? ('"'+column.sql_type+'"') : "#{column.type.inspect}"
            tbl.print ", :limit => #{column.limit.inspect}" if !@types[column.type].nil? and column.limit != @types[column.type][:limit] 
            tbl.print ", :default => #{column.default.inspect}" if !column.default.nil?
            tbl.print ", :null => false" if !column.null
            tbl.puts
          end

  ...

      end

Attachments

patch.diff (1.2 kB) - added by mail@matthewpainter.co.uk on 06/23/06 11:53:17.
Patch against current SVN
patch-updated.diff (1.2 kB) - added by mail@matthewpainter.co.uk on 06/23/06 14:06:11.
Updated patch to allow for double quotes in type

Change History

06/22/06 18:18:35 changed by bitsweat

  • cc set to bitsweat.
  • keywords set to schema dumper.
  • summary changed from [PATCH] SchemaDumper bug to [PATCH] Schema dumper doesn't handle native types correctly.

Thanks! Could you include a unit test to verify the correct behavior?

06/23/06 11:53:17 changed by mail@matthewpainter.co.uk

  • attachment patch.diff added.

Patch against current SVN

06/23/06 11:55:24 changed by mail@matthewpainter.co.uk

Current unit tests pass fine. Testing of this patch is dependent on the type of database, as we are dealing with native types, and not sure how to add extra tests..?

06/23/06 14:06:11 changed by mail@matthewpainter.co.uk

  • attachment patch-updated.diff added.

Updated patch to allow for double quotes in type