Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check subtype limit before using the default limit #19447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,10 @@

*Yves Senn*

* Fixes #19420. When generating schema.rb using Postgres BigInt[] data type
the limit: 8 was not coming through. This caused it to become Int[] data type
after doing a rebuild off of schema.rb.

*Jake Waller*

Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md) for previous changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Array < Type::Value # :nodoc:
end

attr_reader :subtype, :delimiter
delegate :type, :user_input_in_time_zone, to: :subtype
delegate :type, :user_input_in_time_zone, :limit, to: :subtype

def initialize(subtype, delimiter = ',')
@subtype = subtype
Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/schema_dumper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ def test_schema_dump_includes_bigint_default
assert_match %r{t\.integer\s+"bigint_default",\s+limit: 8,\s+default: 0}, output
end

def test_schema_dump_includes_limit_on_array_type
output = standard_dump
assert_match %r{t\.integer\s+"big_int_data_points\",\s+limit: 8,\s+array: true}, output
end

if ActiveRecord::Base.connection.supports_extensions?
def test_schema_dump_includes_extensions
connection = ActiveRecord::Base.connection
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/schema/postgresql_specific_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@
t.binary :binary, limit: 100_000
t.text :text, limit: 100_000
end

create_table :bigint_array, force: true do |t|
t.integer :big_int_data_points, limit: 8, array: true
end
end