Is there any way to create a literal `Op<Boolean>`...
# exposed
a
Is there any way to create a literal
Op<Boolean>
? My issue is that I want to do
Time(MyTable.timestamp).between(startTime, endTime)
, but the
TIME
expression isn't available in Postgres. The way to do it in postgres would be with
table_name.timestamp::time BETWEEN startTime AND endTime
So I would like to do something like:
Copy code
MyTable.select(MyTable.columns)
  .where { literalExpression("my_table.timestamp::time between $startTime AND $endTime") }
Solved it by creating a modified
Time
class instead:
Copy code
public class TimePg<T : Temporal?>(
	public val expr: Expression<T>,
) : Function<LocalTime>(ExposedStatic.LOCAL_TIME_COLUMN) {
	override fun toQueryBuilder(
		queryBuilder: QueryBuilder,
	): Unit = queryBuilder { append(expr, "::time") }
}
s
Does something like this work:
Copy code
MyTable.timestamp.castTo<LocalTime>(JavaLocalTimeColumnType()).between(...)
ie. casting instead of using
::time
a
That seems to do the trick as well, thanks