Skip to content

query_as! implementation which uses FromRow #3040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0xForerunner opened this issue Feb 7, 2024 · 2 comments
Closed

query_as! implementation which uses FromRow #3040

0xForerunner opened this issue Feb 7, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@0xForerunner
Copy link

Is your feature request related to a problem? Please describe.
I'd like to be able to use the static type checking we get from the query_as! macro, but I'd like it to use the FromRow implementation.

This is necessary to concisely query more complicated types who's fields don't implement Decode

Consider something simple like this:

#[derive(Clone, Eq, PartialEq, Hash, Debug, FromRow)]
pub struct MyType {
    #[sqlx(try_from = "i64")]
    pub index: usize,
    #[sqlx(flatten)]
    pub element:  TypeThatImplsFromRow,
}

This would be a PITA to use query_as! due to the limitations I mentioned above.

Describe the solution you'd like
Perhaps something like:

query_as!(MyType as FromRow, "INSERT SQL HERE")

or

query_from!(MyType, "INSERT SQL HERE")

Describe alternatives you've considered
I'm not aware of any.

@0xForerunner 0xForerunner added the enhancement New feature or request label Feb 7, 2024
@saiintbrisson
Copy link
Contributor

Dup of #514. This has been widely requested for a long time now, but the current structure isn't capable of handling such change.

@0xForerunner
Copy link
Author

Sorry about that, somehow I missed that in my search. I'll go ahead and close. Thanks! @saiintbrisson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants