Skip to content

Introduce support to compare two columns in Criteria #1335

Open
@koenpunt

Description

@koenpunt

I'm trying to build a criteria where the resulting SQL should look something like;

OR (start_time = end_time AND start_time >= $1 AND start_time < $2)

The code I'm currently using is;

val startCol = Criteria.where("start_time")
val endCol = Criteria.where("end_time")

startCol.isEqual(startTime)
    .or(
        startCol.`is`(endCol)
            .and(startCol.greaterThanOrEquals(startTime))
            .and(startCol.lessThan(endTime))
    )
)

But unfortunately startCol.`is`(endCol) is not working, because it tries to process the endCol as a value.

I've also tried using SQL.literalOf("end_time") and Column.create("end_time", Table.create("appointments")), but both without success.

Is there a different syntax that can be used to compare 2 columns with each other?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions