Skip to content

Commit

Permalink
Few bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jarredhawkins committed Aug 15, 2024
1 parent db161ca commit a44602d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions acceptance/cases/migration/schema_dumper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ def test_dump_schema_contains_virtual_column
ActiveRecord::SchemaDumper.dump connection, schema
assert schema.string.include?("t.virtual \"full_name\", type: :string, as: \"COALESCE(first_name || ' ', '') || last_name\", stored: true"), schema.string
end

def test_dump_schema_contains_string_array
connection = ActiveRecord::Base.connection
schema = StringIO.new
ActiveRecord::SchemaDumper.dump connection, schema
assert schema.string.include?("t.string \"col_array_string\", array: true"), schema.string
end

def test_dump_schema_index_storing
connection = ActiveRecord::Base.connection
schema = StringIO.new
ActiveRecord::SchemaDumper.dump connection, schema
assert schema.string.include?("t.index [\"last_name\"], name: \"index_singers_on_last_name\", order: { last_name: :asc }, storing: [\"first_name\", \"tracks_count\"]"), schema.string
end
end
end
end
1 change: 1 addition & 0 deletions acceptance/schema/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def create_tables_in_test_schema
t.integer :lock_version
t.virtual :full_name, type: :string, as: "COALESCE(first_name || ' ', '') || last_name", stored: true
end
add_index :singers, :last_name, storing: %i[tracks_count first_name]

if is_7_1_or_higher?
create_table :albums, primary_key: [:singerid, :albumid] do |t|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def prepare_column_options column
spec = { type: schema_type(column).inspect }.merge! spec
end

spec[:array] = true if column.sql_type.start_with?('ARRAY<')

spec
end

Expand Down Expand Up @@ -54,7 +56,7 @@ def index_parts index
index_parts = super
index_parts << "null_filtered: #{index.null_filtered.inspect}" if index.null_filtered
index_parts << "interleave_in: #{index.interleave_in.inspect}" if index.interleave_in
index_parts << "storing: #{format_index_parts index.storing}" if index.storing.present?
index_parts << "storing: #{format_index_parts index.storing.sort}" if index.storing.present?
index_parts
end

Expand Down

0 comments on commit a44602d

Please sign in to comment.