Skip to content

Do not add the test worker suffix twice to a SQLite URI with query params - #351

Open
jamesridgway wants to merge 1 commit into
basecamp:mainfrom
the-curve-consulting:fix-test-workerize-uri-query
Open

jamesridgway wants to merge 1 commit into
basecamp:mainfrom
the-curve-consulting:fix-test-workerize-uri-query

Conversation

@jamesridgway

Copy link
Copy Markdown

The Issue

SQLite#test_workerize adds the test worker suffix to the database name. Rails can call it a second time for the same database configuration (see rails/rails#55769), so the method checks for an existing suffix.

The check covers a file path and a URI without query params. It does not cover a URI with query params, where the suffix goes before the ?. A second call changes

file:storage/foo/main.sqlite3_1?vfs=unix-dotfile

into

file:storage/foo/main.sqlite3_1_1?vfs=unix-dotfile

The primary_uri_db test scenario has a database of this form.

The Change

Split the query params from the path first, then do the same check for all three forms.

The new tests in database_adapters_sqlite_test.rb cover a file path, a URI, and a URI with query params. The test "URI with query params that has the suffix" fails without the change.

…rams

SQLite#test_workerize checks for an existing suffix, because Rails can
call it a second time for the same database configuration (see
rails/rails#55769). The check covered a file path and a URI without
query params. It did not cover a URI with query params, where the suffix
goes before the "?". A second call changed

    file:storage/foo/main.sqlite3_1?vfs=unix-dotfile

into

    file:storage/foo/main.sqlite3_1_1?vfs=unix-dotfile

Split the query params from the path first, then do the same check for
all three forms.
Copilot AI balanced review requested due to automatic review settings September 20, 2026 09:01

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approved

The implementation correctly preserves query parameters while preventing duplicate suffixes and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents duplicate SQLite test-worker suffixes when database URIs include query parameters.

Changes:

  • Separates URI query parameters before checking and appending the suffix.
  • Adds regression tests and changelog documentation.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
lib/​active_record/​tenanted/​database_adapters/​sqlite.rb Makes URI suffixing idempotent with query parameters.
test/​unit/​database_adapters_sqlite_test.rb Tests paths and URIs with and without existing suffixes.
CHANGELOG.md Documents the SQLite URI fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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