Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #10172 from senny/10098_backport

Backport: Correctly parse bigint defaults in PostgreSQL
  • Loading branch information...
commit 68239487bfbb467d1f7e7e33f493257e041a90a8 2 parents 536f316 + a6d9e16
@rafaelfranca rafaelfranca authored
View
6 activerecord/CHANGELOG.md
@@ -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
2  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -142,7 +142,7 @@ def self.extract_value_from_default(default)
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
5 activerecord/test/cases/schema_dumper_test.rb
@@ -206,6 +206,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_xml_shorthand_definition
output = standard_dump
if %r{create_table "postgresql_xml_data_type"} =~ output
View
1  activerecord/test/schema/postgresql_specific_schema.rb
@@ -30,6 +30,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 '--- []
Please sign in to comment.
Something went wrong with that request. Please try again.