Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the DATABASE_URL to command spawned for sqlx-macros #1735

Conversation

CosmicHorrorDev
Copy link
Contributor

Currently cargo sqlx prepare doesn't pass the database url value to the child command spawned for sqlx-macros.

$ DATABASE_URL="..." cargo sqlx prepare

works as expected because sqlx-macros will read the value from the env var which is inherited, but

$ cargo sqlx prepare --database-url "..."

will fail in some way (An existing sqlx-data.json makes it not fail, but causes it to find no queries. No existing sqlx-data.json will lead to a error: failed to find data for query) because the database url isn't being passed to the child process.

It's also worth noting that these changes appear to obey precedence correctly too where

$ DATABASE_URL="A" cargo sqlx prepare --database-url "B"

will lead to "B" being used which should be right. I wasn't certain that the old env var would be overridden until I tested it, but it follows what I would have assumed.

@abonander abonander merged commit feff96c into launchbadge:master Mar 9, 2022
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