1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix that unsigned with zerofill is treated as signed

Fixes #27125.
This commit is contained in:
Ryuta Kamizono 2016-11-21 17:40:05 +09:00
parent 747ddd34ab
commit 32ea84df6f
4 changed files with 9 additions and 2 deletions

View file

@ -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.
*Sergey Alekseev*

View file

@ -693,7 +693,7 @@ module ActiveRecord
def register_integer_type(mapping, key, options) # :nodoc:
mapping.register_type(key) do |sql_type|
if /\bunsigned\z/.match?(sql_type)
if /\bunsigned\b/.match?(sql_type)
Type::UnsignedInteger.new(options)
else
Type::Integer.new(options)

View file

@ -5,7 +5,7 @@ module ActiveRecord
delegate :extra, to: :sql_type_metadata, allow_nil: true
def unsigned?
/\bunsigned\z/.match?(sql_type)
!/\A(?:enum|set)\b/.match?(sql_type) && /\bunsigned\b/.match?(sql_type)
end
def case_sensitive?

View file

@ -48,6 +48,7 @@ class Mysql2UnsignedTypeTest < ActiveRecord::Mysql2TestCase
t.unsigned_bigint :unsigned_bigint_t
t.unsigned_float :unsigned_float_t
t.unsigned_decimal :unsigned_decimal_t, precision: 10, scale: 2
t.column :unsigned_zerofill, "int unsigned zerofill"
end
@connection.columns("unsigned_types").select { |c| /^unsigned_/.match?(c.name) }.each do |column|