Changeset 8969
- Timestamp:
- 03/02/08 04:42:10 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
r8794 r8969 111 111 return :string if field_type =~ /enum/i 112 112 super 113 end 114 115 def extract_limit(sql_type) 116 if sql_type =~ /blob|text/i 117 case sql_type 118 when /tiny/i 119 255 120 when /medium/i 121 16777215 122 when /long/i 123 2147483647 # mysql only allows 2^31-1, not 2^32-1, somewhat inconsistently with the tiny/medium/normal cases 124 else 125 super # we could return 65535 here, but we leave it undecorated by default 126 end 127 else 128 super 129 end 113 130 end 114 131 trunk/activerecord/test/cases/schema_dumper_test.rb
r8757 r8969 116 116 assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved" 117 117 end 118 119 def test_schema_dump_includes_length_for_mysql_blob_and_text_fields 120 output = standard_dump 121 assert_match %r{t.binary\s+"tiny_blob",\s+:limit => 255$}, output 122 assert_match %r{t.binary\s+"normal_blob"$}, output 123 assert_match %r{t.binary\s+"medium_blob",\s+:limit => 16777215$}, output 124 assert_match %r{t.binary\s+"long_blob",\s+:limit => 2147483647$}, output 125 assert_match %r{t.text\s+"tiny_text",\s+:limit => 255$}, output 126 assert_match %r{t.text\s+"normal_text"$}, output 127 assert_match %r{t.text\s+"medium_text",\s+:limit => 16777215$}, output 128 assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output 129 end 118 130 end 119 131 trunk/activerecord/test/schema/schema.rb
r8914 r8969 24 24 create_table :binaries, :force => true do |t| 25 25 t.binary :data 26 end 27 28 create_table :binary_fields, :force => true do |t| 29 t.binary :tiny_blob, :limit => 255 30 t.binary :normal_blob, :limit => 65535 31 t.binary :medium_blob, :limit => 16777215 32 t.binary :long_blob, :limit => 2147483647 33 t.text :tiny_text, :limit => 255 34 t.text :normal_text, :limit => 65535 35 t.text :medium_text, :limit => 16777215 36 t.text :long_text, :limit => 2147483647 26 37 end 27 38