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

Ticket #10963 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

[PATCH] Fix invalid :default => '' for mysql text and binary columns

Reported by: mdeiters Assigned to: core
Priority: normal Milestone: 2.1
Component: ActiveRecord Version: edge
Severity: normal Keywords: mysql text default
Cc:

Description

When the MysqlAdapter attempts to extract the default value for binary and text columns it currently returns an empty string if no default was specified only for mysql but not other databases. If a default is present it raises an error. This produces the unwanted result while generating a schema.rb file:

table.binary :data, :default => , :null => false table.text :some_description, :default => , :null => false

When this schema.rb is loaded into the test database it then produces the following error: Mysql::Error: #42000BLOB/TEXT column 'data' can't have a default value

I have submitted this patch so that the default value for text and binary columns is nil (inline with how other database binary columns behave in ActiveRecord). I am not providing any new tests but fixing two existing tests as they were actually asserting invalid results. This patch will verify and generate a valid schema.rb file that outputs:

table.binary :data, :null => false table.text :some_description, :null => false

Attachments

fix_invalid_default_value_for_mysql_text_and_binary_columns.diff (2.4 kB) - added by mdeiters on 01/30/08 22:40:25.

Change History

01/30/08 22:40:25 changed by mdeiters

  • attachment fix_invalid_default_value_for_mysql_text_and_binary_columns.diff added.

01/30/08 23:22:53 changed by bitsweat

  • keywords set to mysql text default.
  • milestone changed from 2.x to 2.1.

01/30/08 23:23:01 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8757]) MySQL: omit text/blob defaults from the schema instead of using an empty string. Closes #10963.