From 5b144233e9ac3405b029d296a5f231b4caa73859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 14 Oct 2013 01:25:59 -0300 Subject: Extract a function to determine if the default value is a function --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3