aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-03-02 04:42:10 +0000
committerMichael Koziarski <michael@koziarski.com>2008-03-02 04:42:10 +0000
commitc1abe4430684512709976f66634903a4dc147d03 (patch)
treef3b7105fd57645a39d8702d1052151df85e25417 /activerecord/lib
parent4673c47d7beae5bb5a79841d517b5c5d9b22579a (diff)
downloadrails-c1abe4430684512709976f66634903a4dc147d03.tar.gz
rails-c1abe4430684512709976f66634903a4dc147d03.tar.bz2
rails-c1abe4430684512709976f66634903a4dc147d03.zip
Make the mysql schema dumper roundtrip the limits of text/blob columns. Closes #7424 [will.bryant]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8969 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/mysql_adapter.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index c37bfd3e81..6432c3cfee 100755
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -112,6 +112,23 @@ module ActiveRecord
super
end
+ def extract_limit(sql_type)
+ if sql_type =~ /blob|text/i
+ case sql_type
+ when /tiny/i
+ 255
+ when /medium/i
+ 16777215
+ when /long/i
+ 2147483647 # mysql only allows 2^31-1, not 2^32-1, somewhat inconsistently with the tiny/medium/normal cases
+ else
+ super # we could return 65535 here, but we leave it undecorated by default
+ end
+ else
+ super
+ end
+ end
+
# MySQL misreports NOT NULL column default when none is given.
# We can't detect this for columns which may have a legitimate ''
# default (string) but we can for others (integer, datetime, boolean,