Permalink
Browse files

Merge pull request #10098 from subwindow/postgres_dump_bigint_default

Correctly parse bigint defaults in PostgreSQL

Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information...
2 parents 877dfcb + 661365e commit d25e0c6f6a2764fb2605dc216e5c4b26a74f7e97 @rafaelfranca rafaelfranca committed Apr 5, 2013
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Default values for PostgreSQL bigint types now get parsed and dumped to the
+ schema correctly.
+
+ *Erik Peterson*
+
* Fix associations with `:inverse_of` option when building association
with a block. Inside the block the parent object was different then
after the block.
@@ -80,7 +80,7 @@ def self.extract_value_from_default(default)
when /\A'(.*)'::(num|date|tstz|ts|int4|int8)range\z/m
$1
# Numeric types
- when /\A\(?(-?\d+(\.\d*)?\)?)\z/
+ when /\A\(?(-?\d+(\.\d*)?\)?(::bigint)?)\z/
$1
# Character types
when /\A\(?'(.*)'::.*\b(?:character varying|bpchar|text)\z/m
@@ -242,6 +242,11 @@ def test_schema_dump_includes_decimal_options
end
if current_adapter?(:PostgreSQLAdapter)
+ def test_schema_dump_includes_bigint_default
+ output = standard_dump
+ assert_match %r{t.integer\s+"bigint_default",\s+limit: 8,\s+default: 0}, output
+ end
+
def test_schema_dump_includes_extensions
connection = ActiveRecord::Base.connection
skip unless connection.supports_extensions?
@@ -32,6 +32,7 @@
char3 text default 'a text field',
positive_integer integer default 1,
negative_integer integer default -1,
+ bigint_default bigint default 0::bigint,
decimal_number decimal(3,2) default 2.78,
multiline_default text DEFAULT '--- []

0 comments on commit d25e0c6

Please sign in to comment.