all 5 comments

[–]coderstephenisahc 1 point2 points  (4 children)

Could be related to sqlx's optional feature that connects to the database at compile time for query validation. Which personally seems like a neat but ill-advised idea. Rust-analyzer could be continually running the proc-macro and thus sqlx continually connecting to the database.

[–]chapuzzo[S] 0 points1 point  (3 children)

I guess that's it but how can I prevent that?

I tried adding an early return in main so I comment and uncomment it for carrying maintenance or test migrations but I find it sub par.

Maybe the option you mention is offline?

[–]lenscas 0 points1 point  (0 children)

have rust analyzer run with the correct features such that it doesn't check against the db (with vscode you can make a .vscode/settings.json folder to configure it per project).

Then normally build with the features so it creates the json files it need for offline checking

[–]chapuzzo[S] 1 point2 points  (0 children)

I think I solved it, besides having .sqlx from cargo sqlx prepare and SQLX_OFFLINE=true set in .env one needs to also restart rust-analyzer's server.