Permalink
Browse files

Escape the parentheses in the default function regexp

This is causing every default value in PostreSQL database to being
handled as default function.

Fixes #12581
  • Loading branch information...
1 parent 3f2bc99 commit 9a597ea06d684431d2e050c48a98e24edb31b833 @rafaelfranca rafaelfranca committed Oct 21, 2013
View
2 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -143,7 +143,7 @@ def type_cast(value)
private
def has_default_function?(default_value, default)
- !default_value && (%r{\w+(.*)} === default)
+ !default_value && (%r{\w+\(.*\)} === default)
end
def extract_limit(sql_type)
View
5 activerecord/test/cases/schema_dumper_test.rb
@@ -202,6 +202,11 @@ def test_schema_dump_should_honor_nonstandard_primary_keys
assert_match %r(primary_key: "movieid"), match[1], "non-standard primary key not preserved"
end
+ def test_schema_dump_should_use_false_as_default
+ output = standard_dump
+ assert_match %r{t\.boolean\s+"has_fun",.+default: false}, output
+ end
+
if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
def test_schema_dump_should_not_add_default_value_for_mysql_text_field
output = standard_dump

0 comments on commit 9a597ea

Please sign in to comment.