-
Notifications
You must be signed in to change notification settings - Fork 1.4k
query!() is evaluated incorrectly/inconsistently with rust-analyser because of static caching #3738
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
Comments
Changing to a |
How much work do you think this would be? I'm utterly unfamilar with this part of the codebase and proc-macros in general but if this is as simple as replacing a global with a thread local I could probably do that this weekend. This issue currently causes me a lot of grief so I'd be willing to step up and fix it. |
@abonander By collecting all the state do you mean turning
|
Anyone has any workarounds they care to share for this? Currently, we're just pinning an old version of rust-analyzer, but that's becoming less and less convenient with time |
if you accept any ideas - it would be nice to configure where value is coming from. For example: lets call config file [macro]
connection_url = { source = "file", path = ".env", key = "DATABASE_URL" }
connection_url = { source = "cache", location = "path_to_cache_dir_or_folder_idk_specifics" }
connection_url = { source = "local", value = "postgres://..." } |
@abonander oh wow. I haven't been developing in rust for half a year and look how sqlx have improved! <3 |
Actually I don't think it has to be a That also gives us future-proofing in the event macros start to be expanded in parallel. That doesn't seem to be in the cards for the current parallel frontend, but it seems like it'd be an easy perf win in macro-heavy code. |
@abonander if I understand right.... it's possible that this can be worked around by |
@huuff that would also be an option, yes. |
I have found these related issues/pull requests
Not related to any other issue on this repo - sort of related to #121, but not really
Description
This issue happens in workspaces with sqlx, and does not happen in
cargo check
, but does affect rust-analyser.You need two crates in your workspace, and those crates need to use a different database. For example:
Rust-Analyser will incorrectly evaluate
query!()
executions against the wrong database, the right database, or both databases.According to the rust-analyser devs (where this was originally reported), this is the issue:
rust-lang/rust-analyzer#18533 (comment)
Reproduction steps
This repository will reproduce the issue: https://github.com/zkrising/ra-sqlx-repro
A reproduction is available here: https://github.com/zkrising/ra-sqlx-repro
Note that
cargo check
et. al. report no issues, but rust-analyser will. You might have to edit and save themain.rs
files just to get rust-analyser to trip up, but I've found doing that pretty reliably gives you an error that shouldn't exist.The gist of the repro is that there's
sqlite_red
which queriesred_things
andsqlite_yellow
which queriesyellow_things
. Despite the crates working and compiling, rust-analyser will seemingly manifest an error that the table does not exist.SQLx version
0.8
Enabled SQLx features
runtime-tokio, sqlite, but any driver has this issue
Database server and version
sqlite 3.48.0, but any works
Operating system
Linux
Rust version
rustc 1.83.0-nightly (55a22d2a6 2024-10-06)
The text was updated successfully, but these errors were encountered: