Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed bug where enums limit were getting set as 0 #6432

Closed
wants to merge 1 commit into from

3 participants

@thiagofm

This is an old bug where rake db:schema:dump imported all columns with the type enum as :limit => 0, making schema.rb don't work on with anything that relies on it(db:schema:load).

This issue were raised here: https://rails.lighthouseapp.com/projects/8994/tickets/997-dbschemadump-saves-enum-columns-as-varchar0-on-mysql

And there's other posts on the web about it.

I solved it by setting the limit as the biggest enum value string size. I wonder if shouldn't we just set it as like 255 to only make it work.

I think it's also time that rails supports enum columns. There's plugins that do that, but I would gadly make it work.

Feel free to comment about the code or the regexp, I will also gadly change it.

@rafaelfranca

@thiagofm how about the mysql2 adapted? Did you see any way to test this?

@thiagofm

There are no tests... so I will write some tests for it then.

@senny senny added enum and removed enum labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 22, 2012
  1. @thiagofm
This page is out of date. Refresh to see the latest.
View
2  activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -67,6 +67,8 @@ def extract_limit(sql_type)
else
super # we could return 65535 here, but we leave it undecorated by default
end
+ when /^enum\((.*)\)/i
+ $1.split(',').collect{ |value| value.size-2 }.max
when /^bigint/i; 8
when /^int/i; 4
when /^mediumint/i; 3
Something went wrong with that request. Please try again.