Skip to content

Commit

Permalink
fix: EXPOSED-19 Max timestamp in SQLite not working
Browse files Browse the repository at this point in the history
Mark `Function` with `WithColumnType` interface instead of `Max` and `Min`
  • Loading branch information
joc-a committed Apr 19, 2023
1 parent 0f21cfe commit 8866f5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ class AutoIncColumnType(

/** Returns `true` if this is an auto-increment column, `false` otherwise. */
val IColumnType.isAutoInc: Boolean get() = this is AutoIncColumnType || (this is EntityIDColumnType<*> && idColumn.columnType.isAutoInc)

/** Returns the name of the auto-increment sequence of this column. */
val Column<*>.autoIncColumnType: AutoIncColumnType?
get() = (columnType as? AutoIncColumnType) ?: (columnType as? EntityIDColumnType<*>)?.idColumn?.columnType as? AutoIncColumnType

@Deprecated(
message = "Will be removed in upcoming releases. Please use [autoIncColumnType.autoincSeq] instead",
replaceWith = ReplaceWith("this.autoIncColumnType.autoincSeq"),
Expand Down Expand Up @@ -916,7 +918,7 @@ interface IDateColumnType {
}

/**
* Marker interface for columns/expressions with a column type
* Marker interface for columns/expressions with a column type.
*/
interface WithColumnType {
val columnType: IColumnType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.math.BigDecimal
/**
* Represents an SQL function.
*/
abstract class Function<T>(override val columnType: IColumnType) : ExpressionWithColumnType<T>()
abstract class Function<T>(override val columnType: IColumnType) : ExpressionWithColumnType<T>(), WithColumnType

/**
* Represents a custom SQL function.
Expand Down Expand Up @@ -146,11 +146,7 @@ class Min<T : Comparable<T>, in S : T?>(
/** Returns the expression from which the minimum value is obtained. */
val expr: Expression<in S>,
columnType: IColumnType
) : Function<T?>(columnType), WithColumnType {

override val columnType: IColumnType
get() = super.columnType

) : Function<T?>(columnType) {
override fun toQueryBuilder(queryBuilder: QueryBuilder): Unit = queryBuilder { append("MIN(", expr, ")") }
}

Expand All @@ -161,9 +157,7 @@ class Max<T : Comparable<T>, in S : T?>(
/** Returns the expression from which the maximum value is obtained. */
val expr: Expression<in S>,
columnType: IColumnType
) : Function<T?>(columnType), WithColumnType {
override val columnType: IColumnType
get() = super.columnType
) : Function<T?>(columnType) {

override fun toQueryBuilder(queryBuilder: QueryBuilder): Unit = queryBuilder { append("MAX(", expr, ")") }
}
Expand Down

0 comments on commit 8866f5a

Please sign in to comment.