Providing a TypedRow<T>
type that supports lifetimes with a macro
#2661
Labels
enhancement
New feature or request
TypedRow<T>
type that supports lifetimes with a macro
#2661
Is your feature request related to a problem? Please describe.
Currently there is no way (as far as i have found) to use the sqlx macros with data with lifetimes. This means when iterating a lot of
Rows
it can be a significant benefit to use thequery
function and decode from theRow
without additional allocation. While using the functions we loose the benefit of the query being checked at compile time.Describe the solution you'd like
Optimally there would be something like a
TypedRow<T>
wrapper which internally stores aRow
and and has a function likedecode
orget
to actually get the data which might contain lifetimes bounded by the lifetime of the Row.Describe alternatives you've considered
One simple but very non optimal solutions would be to duplicate the query inside something like an inner function inside a macro, but this would either require using the
FromRow
implementation which would lookup by name and not by index or by hand writing a decoding functions which uses the correct order of indices which is tedious and error prone.This functionality could probably be implemented in another crate but i think that would require a lot of duplication from what is already implemented in here.
Additional context
I would love to work on this feature and implement it to improve sqlx and provide this functionality which i, and maybe others also, could benefit from. I probably would need some minor guidance for that but i would love to help.
Thanks for your time :)
The text was updated successfully, but these errors were encountered: