Skip to content

Fix Active Record connection checkout in keyset pagination - #931

Merged
ddnexus merged 1 commit into
ddnexus:devfrom
ollym:fix/active-record-connection-checkout
Oct 18, 2026
Merged

ddnexus merged 1 commit into
ddnexus:devfrom
ollym:fix/active-record-connection-checkout

Conversation

@ollym

@ollym ollym commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

The shared Active Record adapter for Keyset and Keynav calls Relation#connection while quoting SQL identifiers. This raises when ActiveRecord.permanent_connection_checkout = :disallowed, emits deprecation warnings with :deprecated, and can retain a checked-out connection beyond the quoting operation.

Use the relation model's connection_pool.with_connection to scope that work. A connection borrowed here is returned to its pool, while an existing caller-owned lease is preserved. Regression tests cover both cases, and the shared Active Record test setup now disallows deprecated permanent checkouts so the entire API suite checks for them.

Audited the gem, example apps, tests, scripts and tasks using text search and a Prism call scan. This was the only deprecated connection checkout found; fixing the shared adapter covers both Keyset and Keynav.

Validation

  • Confirmed the regression tests fail against the original adapter with the deprecated ActiveRecord::Base.connection error.
  • bundle exec thor test:api:coverage: 608 current-API tests and 597 next-API tests pass; combined line and branch coverage remain 100%.
  • bundle exec thor test:e2e:apps: 19 tests pass.
  • bundle exec rubocop: 208 files, no offenses.

Tested with Ruby 4.0.7 and the locked Active Record 8.1.4 dependencies.

@ddnexus
ddnexus changed the base branch from master to dev October 18, 2026 09:01
@ddnexus
ddnexus merged commit c69aa4c into ddnexus:dev Oct 18, 2026
6 checks passed
@ddnexus

ddnexus commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you!

@ollym
ollym deleted the fix/active-record-connection-checkout branch October 18, 2026 09:18
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