mirror of
https://github.com/github/rails.git
synced 2026-01-08 22:27:56 -05:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 '--- []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user