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

Unable to use nullable reference with lookup #1437

Closed
Martmists-GH opened this issue Jan 19, 2022 · 1 comment · Fixed by #1450
Closed

Unable to use nullable reference with lookup #1437

Martmists-GH opened this issue Jan 19, 2022 · 1 comment · Fixed by #1450

Comments

@Martmists-GH
Copy link

Martmists-GH commented Jan 19, 2022

Definition:

object CommentTable : LongIdTable() {
    val post = reference("post", PostTable)
    val parent = reference("parent", CommentTable).nullable()
    val author = reference("author", UserTable)
    val content = text("content")
    val created = datetime("created")
    val updated = datetime("updated")
}

Code:

val comments = CommentTable.select { CommentTable.post eq id and (CommentTable.parent eq null) }

Error:

Overload resolution ambiguity: 
public open fun <T : Comparable<TypeVariable(T)>, E : EntityID<TypeVariable(T)>?> ExpressionWithColumnType<TypeVariable(E)>.eq(t: TypeVariable(T)?): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder
public open fun <T> ExpressionWithColumnType<TypeVariable(T)>.eq(t: TypeVariable(T)): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder

Additionally, when setting this field:

it[CommentTable.parent] = payload.parent
Type mismatch: inferred type is Long? but TypeVariable(S) was expected
@naftalmm
Copy link
Contributor

naftalmm commented Feb 7, 2022

As a workaround for select expression, you may use the following:

val comments = CommentTable.select { (CommentTable.post eq id) and CommentTable.parent.isNull() }

But it's not clear what's the problem with setting this field. What is payload? Could you provide a minimal reproducible example for this (preferably in a separate issue)?

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 a pull request may close this issue.

2 participants