提交 32ea84df 编写于 作者: R Ryuta Kamizono

Fix that unsigned with zerofill is treated as signed

Fixes #27125.
上级 747ddd34
* Fix that unsigned with zerofill is treated as signed.
Fixes #27125.
*Ryuta Kamizono*
* Fix the uniqueness validation scope with a polymorphic association.
*Sergey Alekseev*
......
......@@ -693,7 +693,7 @@ def initialize_type_map(m) # :nodoc:
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)
......
......@@ -5,7 +5,7 @@ class Column < ConnectionAdapters::Column # :nodoc:
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?
......
......@@ -48,6 +48,7 @@ class UnsignedType < ActiveRecord::Base
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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册