Skip to content

Use with_connection in DistinctValues - #769

Merged
rosa merged 1 commit into
rails:mainfrom
trevorturk:lease-connections-in-distinct-values
Jul 27, 2026
Merged

Use with_connection in DistinctValues#769
rosa merged 1 commit into
rails:mainfrom
trevorturk:lease-connections-in-distinct-values

Conversation

@trevorturk

@trevorturk trevorturk commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The new DistinctValues module from #730 calls connection directly, which causes errors when using config.active_record.permanent_connection_checkout = :disallowed.

This PR wraps the calls in connection_pool.with_connection following the pattern from #652.

…nnection`

Bare `connection` resolves to the deprecated ActiveRecord::Base.connection,
which raises under permanent_connection_checkout = :disallowed on Rails 8.1.
Follows the connection_pool.with_connection pattern from rails#652.
@trevorturk trevorturk changed the title Lease connections in DistinctValues instead of calling deprecated connection Use with_connection in DistinctValues Jul 27, 2026

@rosa rosa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, great catch! Thanks a lot @trevorturk 🙏🏻

@rosa
rosa merged commit 40d6bd5 into rails:main Jul 27, 2026
58 checks passed
@trevorturk
trevorturk deleted the lease-connections-in-distinct-values branch July 27, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants