mirror of https://github.com/rails/rails
Deprecate `unsigned_float` and `unsigned_decimal` short-hand column methods
As of MySQL 8.0.17, the UNSIGNED attribute is deprecated for columns of
type FLOAT, DOUBLE, and DECIMAL. Consider using a simple CHECK
constraint instead for such columns.
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
Just in case existing `schema.rb` is still valid since the schema dumper
dumps un unsigned attribute as `unsigned: true` option.
2ae883cc16/activerecord/test/cases/adapters/abstract_mysql_adapter/unsigned_type_test.rb (L61-L67)
This commit is contained in:
parent
2ae883cc16
commit
d5489754d5
|
@ -1,3 +1,12 @@
|
|||
* Deprecate `unsigned_float` and `unsigned_decimal` short-hand column methods.
|
||||
|
||||
As of MySQL 8.0.17, the UNSIGNED attribute is deprecated for columns of type FLOAT, DOUBLE,
|
||||
and DECIMAL. Consider using a simple CHECK constraint instead for such columns.
|
||||
|
||||
https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
|
||||
|
||||
*Ryuta Kamizono*
|
||||
|
||||
* Drop MySQL 5.5 support.
|
||||
|
||||
MySQL 5.5 is the only version that does not support datetime with precision,
|
||||
|
|
|
@ -42,18 +42,12 @@ module ActiveRecord
|
|||
# :method: unsigned_bigint
|
||||
# :call-seq: unsigned_bigint(*names, **options)
|
||||
|
||||
##
|
||||
# :method: unsigned_float
|
||||
# :call-seq: unsigned_float(*names, **options)
|
||||
|
||||
##
|
||||
# :method: unsigned_decimal
|
||||
# :call-seq: unsigned_decimal(*names, **options)
|
||||
|
||||
included do
|
||||
define_column_methods :blob, :tinyblob, :mediumblob, :longblob,
|
||||
:tinytext, :mediumtext, :longtext, :unsigned_integer, :unsigned_bigint,
|
||||
:unsigned_float, :unsigned_decimal
|
||||
|
||||
deprecate :unsigned_float, :unsigned_decimal, deprecator: ActiveRecord.deprecator
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -49,8 +49,6 @@ class UnsignedTypeTest < ActiveRecord::AbstractMysqlTestCase
|
|||
@connection.change_table("unsigned_types") do |t|
|
||||
t.unsigned_integer :unsigned_integer_t
|
||||
t.unsigned_bigint :unsigned_bigint_t
|
||||
t.unsigned_float :unsigned_float_t
|
||||
t.unsigned_decimal :unsigned_decimal_t, precision: 10, scale: 2
|
||||
end
|
||||
|
||||
@connection.columns("unsigned_types").select { |c| /^unsigned_/.match?(c.name) }.each do |column|
|
||||
|
@ -58,6 +56,17 @@ class UnsignedTypeTest < ActiveRecord::AbstractMysqlTestCase
|
|||
end
|
||||
end
|
||||
|
||||
test "deprecate unsigned_float and unsigned_decimal" do
|
||||
@connection.change_table("unsigned_types") do |t|
|
||||
assert_deprecated(ActiveRecord.deprecator) do
|
||||
t.unsigned_float :unsigned_float_t
|
||||
end
|
||||
assert_deprecated(ActiveRecord.deprecator) do
|
||||
t.unsigned_decimal :unsigned_decimal_t
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "schema dump includes unsigned option" do
|
||||
schema = dump_table_schema "unsigned_types"
|
||||
assert_match %r{t\.integer\s+"unsigned_integer",\s+unsigned: true$}, schema
|
||||
|
|
Loading…
Reference in New Issue