Skip to content

Export SQL numeric operations from diesel::expression::ops::numeric , and auto-type them. #4462

@dessalines

Description

@dessalines

Discussed in #4461

Originally posted by dessalines January 28, 2025
I'd like to use a subtract operation be used as a select_expression.

This gets the number of unread comments in a post: post_aggregates::comments - post_actions::read_comments_amount

This unfortunately can't use auto_type, and I also can't strictly define the type, since the Sub numeric operation is in a private module : diesel::expression::ops::numeric::Sub

My output type should be something like:

diesel::expression::ops::numeric::Sub<
  post_aggregates::comments,
  post_actions::read_comments_amount
>

Is there any way to get the type from a numeric operation?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions