Skip to content

fix(macros): tolerate unreadable dotenv with query source - #4371

Open
Boulea7 wants to merge 1 commit into
transact-rs:mainfrom
Boulea7:fix/4348-dotenv-permission
Open

fix(macros): tolerate unreadable dotenv with query source#4371
Boulea7 wants to merge 1 commit into
transact-rs:mainfrom
Boulea7:fix/4348-dotenv-permission

Conversation

@Boulea7

@Boulea7 Boulea7 commented Aug 10, 2026

Copy link
Copy Markdown

Does your PR solve an issue?

Fixes #4348.

The query macro environment loader now ignores a dotenv I/O error only when DATABASE_URL or SQLX_OFFLINE had already established a usable query source before that file was opened. An I/O error partway through the file that establishes the source is still reported, so later settings such as SQLX_OFFLINE_DIR are not silently skipped. Dotenv parse errors are still reported, and process environment values retain precedence.

Is this a breaking change?

No. This only allows compilation to continue past an unreadable later or parent dotenv file when a query source is already available.

Testing

  • cargo test -p sqlx-macros-core --all-features query::metadata::tests -- --nocapture (9 passed)
  • SQLite macro integration test with DATABASE_URL=sqlite://tests/sqlite/sqlite.db (17 passed)
  • cargo fmt --all -- --check
  • cargo clippy -p sqlx-macros-core --features macros --all-targets -- -D warnings

AI assistance

Developed with AI assistance.

Ignore dotenv I/O errors only when a query source was established before reading that file. Continue to report parse errors and mid-file I/O failures when the current file established the source.

Fixes transact-rs#4348

Developed with AI assistance.

Signed-off-by: zhanglangning <zln1905391059@163.com>
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.

Permission restrictions of dotenv files up the tree prevent build, even if DATABASE_URL present in env or local dotenv

1 participant