Skip to content

Commit

Permalink
Unsigned integer type with 10 digits can potentially contain values
Browse files Browse the repository at this point in the history
which don't fit signed integer type. Regard such columns as Bignum,
so that bigint type will be used in target database.
  • Loading branch information
oldgreen committed May 31, 2012
1 parent 7f2f6e0 commit 3b034b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/sequel/extensions/schema_dumper.rb
Expand Up @@ -149,8 +149,14 @@ def column_schema_to_generator_opts(name, schema, options)
# database type is not recognized, return it as a String type.
def column_schema_to_ruby_type(schema)
case t = schema[:db_type].downcase
when /\A(?:medium|small)?int(?:eger)?(?:\((?:\d+)\))?(?: unsigned)?\z/o
{:type=>Integer}
when /\A(medium|small)?int(?:eger)?(?:\((\d+)\))?( unsigned)?\z/o
if !$1 && $2 && $2.to_i >= 10 && $3
# Unsigned integer type with 10 digits can potentially contain values which
# don't fit signed integer type, so use bigint type in target database.
{:type=>Bignum}
else
{:type=>Integer}
end
when /\Atinyint(?:\((\d+)\))?(?: unsigned)?\z/o
{:type =>schema[:type] == :boolean ? TrueClass : Integer}
when /\Abigint(?:\((?:\d+)\))?(?: unsigned)?\z/o
Expand Down

0 comments on commit 3b034b1

Please sign in to comment.