Bug with my sqlx::query! with postgres
reddit.com·7h·
Discuss: r/rust
Flag this post

Hey everyone,

I have a Postgres database with a table that has several columns. Whenever I alter the table—like adding a new column or constraint—sqlx::query! doesn’t pick up the change.

For example, if I run SELECT * FROM table;, the returned records only include the old columns. Trying to access a new column added via ALTER TABLE (e.g., carlid1) gives this error:

No field `carlid1` in type `Record` [E0609]

This happens every time and sometimes seems to fix itself after a few days, but it’s really frustrating. I suspect it has to do with updating what sqlx knows about the DB schema, but I haven’t found a solution that works.

I’ve already tried:

cargo sqlx prepare (and all its variations)

cargo check

cargo build

Restarting RustRover

Similar Posts

Loading similar posts...