Replies: 2 comments 5 replies
|
Any diesel query DSL function returns exactly that type that is shown in the documentation. For Unfortunately neither RustRover nor Rustc are a help here as they ignore these type definitions and rather show private not-accessible types instead. That's a bug on their side. |
5 replies
|
@weiznich for future reference, I found two ways around this:
fn query<'a>() -> BoxedSqlQuery<'a, diesel::pg::Pg, SqlQuery> {
sql_query("SELECT ... INNER JOIN ...")
.into_boxed()
.bind::<Double, _>(...)
}
fn query() -> impl ExecuteDsl<PgConnection> + QueryFragment<diesel::pg::Pg> |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Backend
PostgreSQL
Diesel version
2.3.0
Diesel Features
postgres
Operating System Version
Amazon Linux 2023
Third party libraries
No response
What do you want to do?
I want to unit test a query on two tables, joined. The query can conditionally have/not have certain filters, so I'm using
.into_boxed()to build the query. The table names arevendorsandvendor_locations.However, when I try to write the return type for the function, I can't find a correct type. The closest I got to is something like:
But this won't compile because
SelectByandJoinOnare not public. I also tried a bunch ofBoxedQueryvariants, but nothing seemed to satisfy the compiler.What's the correct return type here? Ideally I'd be able to do something simple, like:
Compile time error
No response
What code do you already have?
Additional details
If I just use the query, it works fine. So I don't think it's an issue with how I build it. I just can't figure out a correct type, for when I want to extract this to its own function. VSCode and RustRover's autocomplete were of no help, either.
Checklist
All reactions