aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGuo Xiang Tan <tgx_world@hotmail.com>2014-12-01 21:28:50 +0800
committerGuo Xiang Tan <tgx_world@hotmail.com>2014-12-01 22:00:04 +0800
commit0270363f5c3868f921ee028943aca125774afdd5 (patch)
treea36042ccc2f0c246919ab9e42852048457936a9d /activerecord
parent6acd4920c9728478f8e033658fe6c9c1883f59b1 (diff)
downloadrails-0270363f5c3868f921ee028943aca125774afdd5.tar.gz
rails-0270363f5c3868f921ee028943aca125774afdd5.tar.bz2
rails-0270363f5c3868f921ee028943aca125774afdd5.zip
Fix value extracted from negative integers for PostgreSQL.
Fixes: https://github.com/rails/rails/issues/17856.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb2
-rw-r--r--activerecord/test/cases/defaults_test.rb4
2 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 3698957d8d..fd3232e902 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -532,7 +532,7 @@ module ActiveRecord
when 'true', 'false'
default
# Numeric types
- when /\A\(?(-?\d+(\.\d*)?\)?(::bigint)?)\z/
+ when /\A\(?(-?\d+(\.\d*)?)\)?(::bigint)?\z/
$1
# Object identifier types
when /\A-?\d+\z/
diff --git a/activerecord/test/cases/defaults_test.rb b/activerecord/test/cases/defaults_test.rb
index c089e63128..3e6032e266 100644
--- a/activerecord/test/cases/defaults_test.rb
+++ b/activerecord/test/cases/defaults_test.rb
@@ -36,6 +36,10 @@ class DefaultTest < ActiveRecord::TestCase
assert( "--- []\n\n" == Default.columns_hash['multiline_default'].default ||
"--- []\\012\\012" == Default.columns_hash['multiline_default'].default)
end
+
+ def test_default_negative_integer
+ assert_equal "-1", Default.columns_hash['negative_integer'].default
+ end
end
end