Question about sqlx::query!
reddit.com·12w·
Discuss: r/rust

I’m using sqlx::query! to communicate with my PostgreSQL database from my Rust server. I often run into an issue where my queries stop working correctly after I run an ALTER TABLE. The macro doesn’t seem to recognize new columns, sometimes sees the wrong types, etc.

After spending a lot of time trying to fix this, it turns out the problem comes from Rust’s cache. Once I invalidate the cache, everything works again.

So my question is: Is it normal to have to invalidate the cache every time the database schema changes? Or is there a faster way to make Rust Analyzer and sqlx::query! “refresh” the database schema automatically?

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help