Closed
Description
An example of what I would like to see for usage
#[derive(sqlx::Type)]
enum Role { Admin, Staff, Normal, Advisor }
#[sqlx::record]
struct User { id: i32, name: String, role: Role }
let usr: User = sqlx::query_as!("SELECT id, name FROM user")
.fetch_one(&mut conn).await?;
- The
#[sqlx::record]
is merely saying I would be okay with requiring a proc attribute here if we need to inspect the struct and attach additional metadata to inspect later ( which I think we do )
I think this is blocked on Rust stabilizing const_panic
and const_if
. I can't think of another clean way to support this apart from generating a series of const _: () = { ... }
blocks where we enforce the type equivalence (between the SQL result type and the given Rust type).
I'm definitely open to other suggestions though. What @abonander and I don't want though is to significantly degrade the errors.