diff options
author | Aaron Nelson <asn62@cornell.edu> | 2014-04-17 18:33:10 -0400 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2014-05-16 01:39:24 +0930 |
commit | 51de8cee82d61541725ff4c2462b083f37e64017 (patch) | |
tree | 0998c0f15a8279ea3429e1ea00f79823f377e58c /activerecord/test/cases/adapters/mysql | |
parent | 2367dfeb8d7c4596263e60570333278a913c5ffd (diff) | |
download | rails-51de8cee82d61541725ff4c2462b083f37e64017.tar.gz rails-51de8cee82d61541725ff4c2462b083f37e64017.tar.bz2 rails-51de8cee82d61541725ff4c2462b083f37e64017.zip |
Changed extract_limit in class Column to return correct mysql float and double limits
Diffstat (limited to 'activerecord/test/cases/adapters/mysql')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/schema_test.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/schema_test.rb b/activerecord/test/cases/adapters/mysql/schema_test.rb index 807a7a155e..87c5277e64 100644 --- a/activerecord/test/cases/adapters/mysql/schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/schema_test.rb @@ -17,6 +17,44 @@ module ActiveRecord self.table_name = "#{db}.#{table}" def self.name; 'Post'; end end + + @connection.create_table "mysql_doubles" + end + + teardown do + @connection.execute "drop table if exists mysql_doubles" + end + + class MysqlDouble < ActiveRecord::Base + self.table_name = "mysql_doubles" + end + + def test_float_limits + @connection.add_column :mysql_doubles, :float_no_limit, :float + @connection.add_column :mysql_doubles, :float_short, :float, limit: 5 + @connection.add_column :mysql_doubles, :float_long, :float, limit: 53 + + @connection.add_column :mysql_doubles, :float_23, :float, limit: 23 + @connection.add_column :mysql_doubles, :float_24, :float, limit: 24 + @connection.add_column :mysql_doubles, :float_25, :float, limit: 25 + MysqlDouble.reset_column_information + + column_no_limit = MysqlDouble.columns.find { |c| c.name == 'float_no_limit' } + column_short = MysqlDouble.columns.find { |c| c.name == 'float_short' } + column_long = MysqlDouble.columns.find { |c| c.name == 'float_long' } + + column_23 = MysqlDouble.columns.find { |c| c.name == 'float_23' } + column_24 = MysqlDouble.columns.find { |c| c.name == 'float_24' } + column_25 = MysqlDouble.columns.find { |c| c.name == 'float_25' } + + # Mysql floats are precision 0..24, Mysql doubles are precision 25..53 + assert_equal 24, column_no_limit.limit + assert_equal 24, column_short.limit + assert_equal 53, column_long.limit + + assert_equal 24, column_23.limit + assert_equal 24, column_24.limit + assert_equal 53, column_25.limit end def test_schema |