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

Ticket #7048 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

[PATCH] fix for changeset 5937

Reported by: dcmanges Assigned to: bitsweat
Priority: high Milestone: 1.2
Component: ActiveRecord Version: edge
Severity: critical Keywords:
Cc:

Description

[5937] allowed setting a column default to NULL by using :default => nil However, this was also happening on the primary key column, and most adapters specify the default and NOT NULL in the native_database_type hash for :primary_key

I am attaching a fix tested on MySQL and Oracle.

Attachments

fix_for_changeset_5937.diff (2.9 kB) - added by dcmanges on 01/15/07 05:53:00.

Change History

01/15/07 05:53:00 changed by dcmanges

  • attachment fix_for_changeset_5937.diff added.

01/15/07 06:02:28 changed by dcmanges

Summary of why I changed what I did:

I changed SchemaStatements#type_to_sql because it did not allow passing :primary_key to it.

I changed ColumnDefinition#type_to_sql to ColumnDefinition#sql_type because the Oracle adapter was calling the sql_type method (and then rescuing).

Now that this line in the Oracle adapter wasn't rescuing anymore:

%Q{empty_#{ column.sql_type rescue 'blob' }()}

I added a .downcase to return empty_blob() instead of empty_BLOB()

01/15/07 06:04:51 changed by dcmanges

Most importantly in the patch I skipped add_column_options! for :primary_key columns.

01/15/07 06:30:42 changed by mschoen

Patch works for me.

01/15/07 15:48:38 changed by bitsweat

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

(In [5944]) Skip column options for primary keys. Closes #7048.

01/15/07 15:51:55 changed by bitsweat

(In [5945]) Merge [5944] from trunk. References #7048.