Skip to content

Support for sum() with complex CASE expressions returning BasicColumn #828

Closed
@hanbonghun

Description

@hanbonghun

Hello I'm trying to use a complex CASE expression within a sum() function, but I'm encountering difficulties due to type incompatibility. Here's an example of what I'm trying to achieve:

sum(case_()
    .when(
        statusCode, isEqualTo(ACCEPT_PROGRESS)
    )
    .then(1)
    .else_(0)
    .end()).as("receivedVocCount")

The issue arises because the end() method returns a BasicColumn, but the sum() function expects a BindableColumn. This makes it impossible to use complex CASE expressions directly within aggregate functions like sum().
I have two questions:

Is there currently any supported way to use complex CASE expressions within aggregate functions like sum()?
If not, what would be the recommended approach to extend the functionality to support this use case? Are there specific interfaces or classes that I should implement or extend to make this work?

Any guidance or suggestions would be greatly appreciated. This functionality would be very useful for creating more complex and flexible queries using MyBatis Dynamic SQL.
Thank you for your time and consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions