Skip to content
Browse files

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

  • Loading branch information...
1 parent 9cd5f2e commit 066a94aa91aacc0f5687ad42e7b2b84c6f54a938 @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:
@@ -142,6 +142,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 066a94a

Please sign in to comment.
Something went wrong with that request. Please try again.