JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.05k stars 676 forks source link

fix: Tests `testAdjustQueryHaving`, `testQueryAndHaving`, and `testQueryOrHaving` resolve wrong `eq` function, and `testGroupBy03` shows compiler warning #2016

Closed joc-a closed 4 months ago

joc-a commented 4 months ago

The tests testAdjustQueryHaving, testQueryAndHaving, and testQueryOrHaving falsely resolve this eq function

infix fun <T : Comparable, V : T?, E : EntityID?> Expression.eq( other: ExpressionWithColumnType ): Op = other eq this

instead of this

infix fun <T, S1 : T?, S2 : T?> Expression.eq(other: Expression): Op = when (other as Expression<*>) { is Op.NULL -> isNull() else -> EqOp(this, other) }

The same happens when using neq, less, lessEq, greater, and greaterEq, so those are fixed in this commit too.

Even when the correct function is resolved, a compiler warning still shows up because the compiler cannot infer the type of the argument when Long and Int are being compared. To remove the warning, the types are explicitly passed to the eq function like this .eq<Number, Long, Int>.

This was tested with Kotlin 2.0.0-Beta4.

joc-a commented 4 months ago

@joc-a Could you please confirm that this doesn't reintroduce any of the highlighted compiler warning issues detailed in PR #1961 and #1984 ? There are no tests for these warnings, just have to confirm with examples in the IDE and maybe running compileTestKotlin. Especially since Count and Max return different types.

Confirmed by running compileTestKotlin with the Kotlin version set to 2.0.0-Beta4 ✅