Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

joc-a
Copy link
Collaborator

@joc-a joc-a commented Feb 29, 2024

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 joc-a marked this pull request as ready for review February 29, 2024 21:35
@joc-a joc-a requested review from bog-walk and e5l February 29, 2024 21:35
Copy link
Member

@bog-walk bog-walk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

…eryOrHaving` resolve wrong `eq` function, and `testGroupBy03` shows compiler warning

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

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

instead of this

infix fun <T, S1 : T?, S2 : T?> Expression<in S1>.eq(other: Expression<in S2>): Op<Boolean> = 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 joc-a force-pushed the joc/fix-false-resolved-eq branch from 3f0deff to e18bf33 Compare March 1, 2024 13:37
@joc-a joc-a changed the title fix: Tests testAdjustQueryHaving, testQueryAndHaving, and testQueryOrHaving resolve wrong eq function fix: Tests testAdjustQueryHaving, testQueryAndHaving, and testQueryOrHaving resolve wrong eq function, and testGroupBy03 shows compiler warning Mar 1, 2024
@joc-a
Copy link
Collaborator Author

joc-a commented Mar 1, 2024

@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 ✅

@joc-a joc-a merged commit b547376 into main Mar 4, 2024
5 checks passed
@joc-a joc-a deleted the joc/fix-false-resolved-eq branch March 4, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants