Skip to content

How to write a where clause using a function #219

Answered by efenderbosch
efenderbosch asked this question in Q&A
Discussion options

You must be logged in to vote

I got something working, but I'm not sure if this is the right way to do it.

enum class TimestampAddUnit(val mysqlName: String) {
    Microsecond("MICROSECOND"),
    Second("SECOND"),
    Minute("MINUTE"),
    Hour("HOUR"),
    Day("DAY"),
    Week("WEEK"),
    Month("MONTH"),
    Quarter("QUARTER"),
    Year("YEAR")
}

fun timestampAdd(
    durationColumn: Column<NumberOfMinutes>,
    unit: TimestampAddUnit,
    timeColumn: Column<LocalTime>
): FunctionExpression<LocalTime> {
    return FunctionExpression(
        functionName = "TIMESTAMPADD",
        arguments = listOf(
            LiteralSqlExpression(unit.mysqlName),
            durationColumn.asExpression(),
            timeColumn.a…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@vincentlauvlwj
Comment options

Answer selected by vincentlauvlwj
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants