Skip to content

Define the order() argument from a variable #2991

Answered by weiznich
agateau asked this question in Q&A
Discussion options

You must be logged in to vote

As the compiler message says each match arm returns a different type. That's expected as each column type is it's own distinct type. See the Schema in depth guide for details about what is produced by diesel's table! macro internally.

Now there are multiple ways to "solve" your problem:

  • Construct the query before the match statement, use .into_boxed() to produce a stable query type and then apply the order in each match arm
  • Use BoxableExpression to construct a compatible common trait object based on your expressions.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@agateau
Comment options

Answer selected by agateau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants