Skip to content

Commit 2271f7d

Browse files
committed
Merge pull request rails#19447 from wallerjake/postgresql_big_int_array_schema_rb
Check subtype limit before using the default limit
2 parents b663e26 + 9bc4eb7 commit 2271f7d

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

activerecord/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,4 +698,10 @@
698698

699699
*Yves Senn*
700700

701+
* Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
702+
the limit: 8 was not coming through. This caused it to become Int[] data type
703+
after doing a rebuild off of schema.rb.
704+
705+
*Jake Waller*
706+
701707
Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.

activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Array < Type::Value # :nodoc:
1818
end
1919

2020
attr_reader :subtype, :delimiter
21-
delegate :type, :user_input_in_time_zone, to: :subtype
21+
delegate :type, :user_input_in_time_zone, :limit, to: :subtype
2222

2323
def initialize(subtype, delimiter = ',')
2424
@subtype = subtype

activerecord/test/cases/schema_dumper_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ def test_schema_dump_includes_bigint_default
248248
assert_match %r{t\.integer\s+"bigint_default",\s+limit: 8,\s+default: 0}, output
249249
end
250250

251+
def test_schema_dump_includes_limit_on_array_type
252+
output = standard_dump
253+
assert_match %r{t\.integer\s+"big_int_data_points\",\s+limit: 8,\s+array: true}, output
254+
end
255+
251256
if ActiveRecord::Base.connection.supports_extensions?
252257
def test_schema_dump_includes_extensions
253258
connection = ActiveRecord::Base.connection

activerecord/test/schema/postgresql_specific_schema.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@
9393
t.binary :binary, limit: 100_000
9494
t.text :text, limit: 100_000
9595
end
96+
97+
create_table :bigint_array, force: true do |t|
98+
t.integer :big_int_data_points, limit: 8, array: true
99+
end
96100
end

0 commit comments

Comments
 (0)