Skip to content

Commit

Permalink
Merge pull request #10098 from subwindow/postgres_dump_bigint_default
Browse files Browse the repository at this point in the history
Correctly parse bigint defaults in PostgreSQL

Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information
rafaelfranca committed Apr 5, 2013
2 parents 877dfcb + 661365e commit d25e0c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions activerecord/CHANGELOG.md
@@ -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.
Expand Down
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/schema_dumper_test.rb
Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions activerecord/test/schema/postgresql_specific_schema.rb
Expand Up @@ -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 '--- []
Expand Down

0 comments on commit d25e0c6

Please sign in to comment.