Skip to content

Commit

Permalink
fix: EXPOSED-280 Comparison operators show incorrect compiler warning…
Browse files Browse the repository at this point in the history
… with datetime columns (#1984)

An incorrect compiler warning is flagged if a comparison operator, like eq(),
is used with 2 columns that store certain types. The warning treats the right-side
column as an EntityID column. The pattern so far seems to be stored types that are
not part of the Kotlin standard library, namely javatime, jodatime, and UUID types.

This occurs because of recently introduced convenience overrides that are being
inappropriately chosen. These overrides incorrectly make the ExpressionWithColumnType
argument's type parameter contravariant, when this annotation should instead be
set on the calling Expression object's type parameter.
  • Loading branch information
bog-walk authored Feb 5, 2024
1 parent 46dc765 commit 6732924
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ interface ISqlExpressionBuilder {
}

/** Checks if this expression is equal to some [other] [EntityID] expression. */
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<V>.eq(
other: ExpressionWithColumnType<in E>
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<in V>.eq(
other: ExpressionWithColumnType<E>
): Op<Boolean> = other eq this

// NOT EQUAL
Expand Down Expand Up @@ -297,8 +297,8 @@ interface ISqlExpressionBuilder {
}

/** Checks if this expression is not equal to some [other] [EntityID] expression. */
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<V>.neq(
other: ExpressionWithColumnType<in E>
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<in V>.neq(
other: ExpressionWithColumnType<E>
): Op<Boolean> = other neq this

// LESS THAN
Expand All @@ -320,8 +320,8 @@ interface ISqlExpressionBuilder {
): LessOp = LessOp(this, other)

/** Checks if this expression is less than some [other] [EntityID] expression. */
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<V>.less(
other: ExpressionWithColumnType<in E>
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<in V>.less(
other: ExpressionWithColumnType<E>
): LessOp = LessOp(this, other)

// LESS THAN OR EQUAL
Expand All @@ -343,8 +343,8 @@ interface ISqlExpressionBuilder {
): LessEqOp = LessEqOp(this, other)

/** Checks if this expression is less than or equal to some [other] [EntityID] expression. */
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<V>.lessEq(
other: ExpressionWithColumnType<in E>
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<in V>.lessEq(
other: ExpressionWithColumnType<E>
): LessEqOp = LessEqOp(this, other)

// GREATER THAN
Expand All @@ -366,8 +366,8 @@ interface ISqlExpressionBuilder {
): GreaterOp = GreaterOp(this, other)

/** Checks if this expression is greater than some [other] [EntityID] expression. */
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<V>.greater(
other: ExpressionWithColumnType<in E>
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<in V>.greater(
other: ExpressionWithColumnType<E>
): GreaterOp = GreaterOp(this, other)

// GREATER THAN OR EQUAL
Expand All @@ -389,8 +389,8 @@ interface ISqlExpressionBuilder {
): GreaterEqOp = GreaterEqOp(this, other)

/** Checks if this expression is greater than or equal to some [other] [EntityID] expression. */
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<V>.greaterEq(
other: ExpressionWithColumnType<in E>
infix fun <T : Comparable<T>, V : T?, E : EntityID<T>?> Expression<in V>.greaterEq(
other: ExpressionWithColumnType<E>
): GreaterEqOp = GreaterEqOp(this, other)

// Comparison Predicates
Expand Down

0 comments on commit 6732924

Please sign in to comment.