Permalink
Browse files

Merge pull request #27329 from kamipo/simplify_unsigned_regex

Simplify the regex for `unsigned?` method
  • Loading branch information...
eileencodes committed Dec 17, 2016
2 parents a8a062c + 61cd7bd commit 5b37c9c4a6d823ea210e46ad5f57b1a437243e7d
@@ -5,8 +5,7 @@ class Column < ConnectionAdapters::Column # :nodoc:
delegate :extra, to: :sql_type_metadata, allow_nil: true
def unsigned?
# enum and set types do not allow being defined as unsigned.
!/\A(?:enum|set)\b/.match?(sql_type) && /\bunsigned\b/.match?(sql_type)
/\bunsigned(?: zerofill)?\z/.match?(sql_type)
end
def case_sensitive?
@@ -15,6 +15,7 @@ class UnsignedType < ActiveRecord::Base
t.bigint :unsigned_bigint, unsigned: true
t.float :unsigned_float, unsigned: true
t.decimal :unsigned_decimal, unsigned: true, precision: 10, scale: 2
t.column :unsigned_zerofill, "int unsigned zerofill"
end
end
@@ -48,7 +49,6 @@ 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|

0 comments on commit 5b37c9c

Please sign in to comment.