You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to construct the following query using the DSL;
SELECT opening_hours.*FROM opening_hours
WHEREopening_hours.valid_from>= COALESCE(
(
SELECTMAX(opening_hours.valid_from) FROM opening_hours
WHEREopening_hours.merchant_id= $1ANDopening_hours.product_id IS NULLANDopening_hours.valid_from<= $2
),
$2
)
ANDopening_hours.merchant_id= $1ANDopening_hours.product_id IS NULLANDopening_hours.valid_from<= $3ORDER BYopening_hours.valid_fromASC
The inner select in the coalesce is build like this:
val innerSelect =Select.builder()
.select(Expressions.just("MAX($validFrom)"))
.from(table)
.where(merchantIdCondition)
.and(productIdCondition)
.and(validFrom.isLessOrEqualTo(startMarker))
.build()
But passing that select to SimpleFunction.create doesn't work;
val minValue =SimpleFunction.create("COALESCE", listOf(innerSelect, startMarker))
I did see the SubselectExpression, but its constructor isn't public. Implementing the same class with an accessible constructor resulted in a query where only the conditions were rendered, but not the SELECT ... FROM ... WHERE part.
I'm now working around this by explicitly rendering the nested select;
val minValidFrom =Expressions.just(
"(${sqlRenderer.render(innerSelect)})"
)
val minValue =SimpleFunction.create("COALESCE", listOf(minValidFrom, startMarker))
but it would be preferred if rendering was handled by the framework. Is this in any way possible?
The text was updated successfully, but these errors were encountered:
I'm trying to construct the following query using the DSL;
The inner select in the coalesce is build like this:
But passing that select to
SimpleFunction.create
doesn't work;I did see the
SubselectExpression
, but its constructor isn't public. Implementing the same class with an accessible constructor resulted in a query where only the conditions were rendered, but not theSELECT ... FROM ... WHERE
part.I'm now working around this by explicitly rendering the nested select;
but it would be preferred if rendering was handled by the framework. Is this in any way possible?
The text was updated successfully, but these errors were encountered: