Skip to content

fix(sqlite): allow native file URIs for in-memory databases - #1452

Open
sergioperezcheco wants to merge 1 commit into
golang-migrate:masterfrom
sergioperezcheco:fix/sqlite-file-uri-20261004
Open

sergioperezcheco wants to merge 1 commit into
golang-migrate:masterfrom
sergioperezcheco:fix/sqlite-file-uri-20261004

Conversation

@sergioperezcheco

Copy link
Copy Markdown

Fix SQLite file URI parsing

Fixes #878.

sqlite://file:NAME?mode=memory currently reaches net/url.Parse with file:NAME in the URL authority, so the filename is rejected as an invalid port before SQLite is opened. Strip the migrate wrapper first for SQLite file: URIs, leaving ordinary SQLite paths on their existing parsing path.

The regression uses the public database.Open API, applies SQL, writes/reads migration versions, and opens a second SQLite connection to verify named shared-memory behavior and the custom migrations table. A regular on-disk SQLite database remains a control.

Validation on Go 1.26.4 / macOS arm64:

  • Original production code: file URI regression fails; regular file control passes.
  • go test -race -count=1 ./database/sqlite: passes.
  • go vet ./database/sqlite: passes.
  • Parent verification: SQLite package race tests and root-package tests pass.
  • Repository-configured golangci-lint run --new-from-rev=HEAD ./database/sqlite/... with locally available v2.12.2: 0 issues.
  • git diff --check: passes.

Not run: repository-wide database/Docker suite, CI's exact golangci-lint v2.11.4, other Go/OS combinations. PR #1406 changes percent-encoded ordinary path handling after parsing, not this pre-parse file: URI failure; its opaque-URI integration needs care if both changes are merged.

From Hermes Agent (Nous Research), using gpt-6.1-sol. No human-review claim.

Co-authored-by: Hermes Agent <hermes-agent@nousresearch.com>
Signed-off-by: sergioperezcheco <checo520@outlook.com>
@sergioperezcheco

Copy link
Copy Markdown
Author

The Go 1.25 job failed while waiting for the SQL Server 2025 test container to become ready (Test/testMsiFalse/mcr.microsoft.com/mssql/server:2025-latest, database/sqlserver); the SQLite package, including TestOpenFileMemoryURI, passed, and lint passed. The changes here are limited to database/sqlite. Could you rerun CI to check whether the SQL Server container startup failure persists?

This branch has not been deployed

No deployments
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.

Unable to execute sqlite migrations in memory mode on sqlite driver

1 participant