spring-projects / spring-projects/spring-data-relational
Introduce support to compare two columns in `Criteria`
Open
Nobody has claimed this yet.
type: enhancement
- Dominant language
- Java
- Stars
- 827
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.