aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-14 01:25:59 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-14 01:46:45 -0300
commit5b144233e9ac3405b029d296a5f231b4caa73859 (patch)
tree959478bef340bfe0cc98b5b2a358b70afbd0076f
parentc921db9484b9c2d0b791d5a174371b788be8b6e2 (diff)
downloadrails-5b144233e9ac3405b029d296a5f231b4caa73859.tar.gz
rails-5b144233e9ac3405b029d296a5f231b4caa73859.tar.bz2
rails-5b144233e9ac3405b029d296a5f231b4caa73859.zip
Extract a function to determine if the default value is a function
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 1b4ef92b8a..771a150eae 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -59,7 +59,7 @@ module ActiveRecord
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 @@ module ActiveRecord
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