-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Macros: add option to surface warning notices as errors #3133
Comments
This is not a bug. If Postgres returns a successful parse result, we have no way of knowing the query is invalid. SQLx doesn't null-check bind parameters or do any sort of analysis on the query itself, only the metadata that Postgres returns. In this situation, Postgres is likely returning a non-fatal warning message alongside the parse result, which we currently don't have a good way to surface. Unfortunately, emitting lint warnings from proc macros has been unstable for 6 years and doesn't look to be getting stabilized anytime soon. And turning any non-fatal warnings into compiler errors for all users would be an unacceptable breaking change. We've talked about implementing a Clippy-like linter for SQLx, but that's a whole project in and of itself. We could use the I think instead, we could make it optional to elevate these warnings to errors, either using an environment variable (e.g. |
Despite having already read issues about SQLx not null-checking, I had the illusion it did in my case and only altering the table was the issue. Yeah, should've definitely rechecked that. Either way, the latter idea to provide an option to elevate warnings to errors sounds very useful to me. I think the ability to store the option to a file is crucial for reliability (opposed to remembering setting the environment variable every new session). If using an environment variable includes the option to write it into e.g. the |
Bug Description
Given an already existing table, e.g:
when adding a second column to the table, and adding a NOT NULL constraint, e.g.
sqlx::query!
will not throw a compile time error for the following query:While the new column itself is detected (e.g. for select queries), any later added
NOT NULL
constraints are apparently completely ignored.Minimal Reproduction
Minimal github project
Info
rustc --version
: rustc 1.76.0 (07dca489a 2024-02-04)The text was updated successfully, but these errors were encountered: