diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-14 01:25:59 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-14 01:46:45 -0300 |
commit | 5b144233e9ac3405b029d296a5f231b4caa73859 (patch) | |
tree | 959478bef340bfe0cc98b5b2a358b70afbd0076f | |
parent | c921db9484b9c2d0b791d5a174371b788be8b6e2 (diff) | |
download | rails-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.rb | 6 |
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 |