Skip to content

Commit

Permalink
Extract a function to determine if the default value is a function
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Oct 14, 2013
1 parent 9cd5f2e commit 066a94a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def initialize(name, default, oid_type, sql_type = nil, null = true)
super(name, default_value, sql_type, null) super(name, default_value, sql_type, null)
end end


@default_function = default if !default_value && default && default =~ /.+\(.*\)/ @default_function = default if has_default_function?(default_value, default)
end end


# :stopdoc: # :stopdoc:
Expand Down Expand Up @@ -142,6 +142,10 @@ def type_cast(value)


private private


def has_default_function?(default_value, default)
!default_value && (%r{\w+(.*)} === default)
end

def extract_limit(sql_type) def extract_limit(sql_type)
case sql_type case sql_type
when /^bigint/i; 8 when /^bigint/i; 8
Expand Down

0 comments on commit 066a94a

Please sign in to comment.