1
0
Fork 0
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:
Rafael França 2016-11-29 11:10:39 -05:00 committed by GitHub
commit 4806317b65
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|