mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #27126 from kamipo/fix_unsigned_with_zerofill
Fix that unsigned with zerofill is treated as signed
This commit is contained in:
commit
4806317b65
4 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
* Fix that unsigned with zerofill is treated as signed.
|
||||||
|
|
||||||
|
Fixes #27125.
|
||||||
|
|
||||||
|
*Ryuta Kamizono*
|
||||||
|
|
||||||
* Fix the uniqueness validation scope with a polymorphic association.
|
* Fix the uniqueness validation scope with a polymorphic association.
|
||||||
|
|
||||||
*Sergey Alekseev*
|
*Sergey Alekseev*
|
||||||
|
|
|
@ -693,7 +693,7 @@ module ActiveRecord
|
||||||
|
|
||||||
def register_integer_type(mapping, key, options) # :nodoc:
|
def register_integer_type(mapping, key, options) # :nodoc:
|
||||||
mapping.register_type(key) do |sql_type|
|
mapping.register_type(key) do |sql_type|
|
||||||
if /\bunsigned\z/.match?(sql_type)
|
if /\bunsigned\b/.match?(sql_type)
|
||||||
Type::UnsignedInteger.new(options)
|
Type::UnsignedInteger.new(options)
|
||||||
else
|
else
|
||||||
Type::Integer.new(options)
|
Type::Integer.new(options)
|
||||||
|
|
|
@ -5,7 +5,7 @@ module ActiveRecord
|
||||||
delegate :extra, to: :sql_type_metadata, allow_nil: true
|
delegate :extra, to: :sql_type_metadata, allow_nil: true
|
||||||
|
|
||||||
def unsigned?
|
def unsigned?
|
||||||
/\bunsigned\z/.match?(sql_type)
|
!/\A(?:enum|set)\b/.match?(sql_type) && /\bunsigned\b/.match?(sql_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def case_sensitive?
|
def case_sensitive?
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Mysql2UnsignedTypeTest < ActiveRecord::Mysql2TestCase
|
||||||
t.unsigned_bigint :unsigned_bigint_t
|
t.unsigned_bigint :unsigned_bigint_t
|
||||||
t.unsigned_float :unsigned_float_t
|
t.unsigned_float :unsigned_float_t
|
||||||
t.unsigned_decimal :unsigned_decimal_t, precision: 10, scale: 2
|
t.unsigned_decimal :unsigned_decimal_t, precision: 10, scale: 2
|
||||||
|
t.column :unsigned_zerofill, "int unsigned zerofill"
|
||||||
end
|
end
|
||||||
|
|
||||||
@connection.columns("unsigned_types").select { |c| /^unsigned_/.match?(c.name) }.each do |column|
|
@connection.columns("unsigned_types").select { |c| /^unsigned_/.match?(c.name) }.each do |column|
|
||||||
|
|
Loading…
Reference in a new issue