Browse files

Extract a function to determine if the default value is a function

  • Loading branch information...
1 parent c921db9 commit 5b144233e9ac3405b029d296a5f231b4caa73859 @rafaelfranca rafaelfranca committed Oct 14, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
6 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -59,7 +59,7 @@ def initialize(name, default, oid_type, sql_type = nil, null = true)
super(name, default_value, sql_type, null)
end
- @default_function = default if !default_value && default && default =~ /.+\(.*\)/
+ @default_function = default if has_default_function?(default_value, default)
end
# :stopdoc:
@@ -150,6 +150,10 @@ def type_cast(value)
private
+ def has_default_function?(default_value, default)
+ !default_value && (%r{\w+(.*)} === default)
+ end
+
def extract_limit(sql_type)
case sql_type
when /^bigint/i; 8

0 comments on commit 5b14423

Please sign in to comment.