Correctly parse bigint defaults in PostgreSQL, Backpost #10098.

Conflicts:

	activerecord/CHANGELOG.md
	activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
	activerecord/test/cases/schema_dumper_test.rb
This commit is contained in:
Erik Peterson
2013-04-04 21:06:52 -04:00
committed by Yves Senn
parent 536f316cd3
commit a6d9e16e41
4 changed files with 13 additions and 1 deletions

View File

@@ -1,5 +1,11 @@
## unreleased ##
* Default values for PostgreSQL bigint types now get parsed and dumped to the
schema correctly.
Backport #10098.
*Erik Peterson*
* Removed warning when `auto_explain_threshold_in_seconds` is set and the
connection adapter doesn't support explain.
This is causing a regression since the Active Record Railtie is trying to

View File

@@ -142,7 +142,7 @@ module ActiveRecord
when NilClass
nil
# 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

View File

@@ -206,6 +206,11 @@ class SchemaDumperTest < ActiveRecord::TestCase
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_xml_shorthand_definition
output = standard_dump
if %r{create_table "postgresql_xml_data_type"} =~ output

View File

@@ -30,6 +30,7 @@ ActiveRecord::Schema.define do
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 '--- []