sqlx: query_as! macros do not use FromRow
instead the query_as! macro’s directly build the target struct, while it might be nice not to have to derive FromRow for the struct, this also means that you can’t customize the behaviour with a custom FromRow implementation.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 17
- Comments: 22 (3 by maintainers)
Has any work been done on this? If not I’d be willing to try and help contribute this feature.
I’m sure adding more docs would be appreciated 😉
I’ve just wrote my own implementation. Is it safe enough? And is it something you was looking for?
Ah, thanks.
const_panicis still a necessary feature for this, though, otherwise we can’t control the error message. There’s been some promising discussion on the tracking issue so I think I could push it through the stabilization process if I can find the time: https://github.com/rust-lang/rust/issues/51999It can, but I’m not really happy about how the compiler currently handles const panics: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=33e7700ac709e6581dcf478fb3c3b3b4
I proposed a format that would be more useful to us during the feature’s development, but it was brushed off: https://github.com/rust-lang/rust/issues/51999#issuecomment-651022782
We also can’t use
Type::compatible()since trait methods can’t be invoked inconstwhich would necessitate some more codegen hackery, like generating a#[doc(hidden)] pub const fnmethod in an inherent impl with#[derive(Type)].