Friday, October 3, 2025

Virtual columns, real bugfixes

Posted by Claudio Baccigalupo

Hi, it’s Claudio Baccigalupo. Let’s explore this week’s changes in the Rails codebase.

Bump PostgreSQL client version to 18

The PostgreSQL client version in the devcontainer now points to the latest release of PostgreSQL, which is great because…

Support virtual generated columns on PostgreSQL 18+

PostgreSQL 18 supports virtual (not persisted) columns, which can be added in Rails migrations with stored: false. For instance:

create_table :users do |t|
    t.string :name
    t.virtual :lower_name,  type: :string,  as: "LOWER(name)", stored: false
    t.virtual :name_length, type: :integer, as: "LENGTH(name)"
end

Fix Enumerable#sole when element is a tuple

Restores the original behavior so that calling Enumerable#sole on a tuple returns the full tuple (same as Enumerable#first).

Don’t leave parallel tests hanging when worker processes die

When parallel tests are running and a worker process dies abruptly, the test suite would hang forever. This fix now tracks PIDs alongside worker IDs, allowing it to map dead processes back to their worker entries for cleanup.

Stop escaping JS separators in JSON by default

Historically LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) were not valid inside JavaScript literal strings but that changed in ECMAScript 2019, so there is no need to escape them anymore.

Don’t output deprecated message in newly generated applications

Prevents a depreciation message about raise_on_open_redirects from being shown in newly generated applications.

Don’t raise NameError when class_attribute is defined on a singleton

Defining class_attribute on an instance’s singleton class and then accessing the attribute through the instance was raising a NameError.

Add replicas to test database parallelization setup

Setup and configuration of databases for parallel testing now includes replicas. This fixes an issue where integration tests running in parallel would select the base test database instead of the numbered parallel worker database.

Add setting for logging redirect source locations

Redirects are used a lot and often defined in different locations for different purposes (authentication, authorization, fallbacks). A new config setting action_dispatch.verbose_redirect_logs is introduced to log the source location of all redirects.

Don’t let ActiveRecord#select generate duplicate columns

Fixes an issue in Rails 8.1.0.beta1 where using select in a subquery with distinct would cause a SQL error.

Prefer changed_for_autosave?

Fixes a regression in Rails 8.0.2 where previously valid models could become invalid through autosave when a distantly related record was deleted via nested attributes.

Clearing optional composite keys in belongs_to should preserve primary keys

Fixes an Active Record issue where trying to unset composite foreign key associations would raise an error.

You can view the whole list of changes here. We had 15 contributors to the Rails codebase this past week!

Until next time!

Subscribe to get these updates mailed to you.