Correctly parse bigint defaults in PostgreSQL

This commit is contained in:
Erik Peterson 2013-04-04 21:06:52 -04:00
parent dce398d579
commit 661365e7ce
4 changed files with 12 additions and 1 deletions

@ -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*
* `has_many` using `:through` now obeys the order clause mentioned in
through association. Fixes #10016.

@ -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 '--- []