我正在尝试根据可为空的引用列从表中选择行。如果你只用一个标准整数列替换引用并保持它可以为空,它处理 eq 就好了。我也尝试用 optReference 替换引用,但这并没有什么不同。
错误是由编译器给出的。
None of the following functions can be called with the arguments supplied.
Expression<in EntityID<Int>?>.eq(Expression<in EntityID<Int>?>) where T = EntityID<Int>?, S1 = EntityID<Int>?, S2 = EntityID<Int>? for infix fun <T, S1 : T?, S2 : T?> Expression<in S1>.eq(other: Expression<in S2>): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder
ExpressionWithColumnType<T>.eq(T) where T cannot be inferred for infix fun <T> ExpressionWithColumnType<T>.eq(t: T): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder
ExpressionWithColumnType<EntityID<Int>>.eq(Int?) where T = Int for infix fun <T : Comparable<T>> ExpressionWithColumnType<EntityID<T>>.eq(t: T?): Op<Boolean> defined in org.jetbrains.exposed.sql.SqlExpressionBuilder
显示 Intellij 给出的错误的基本工作示例。
object A : IntIdTable("a") {
val n = varchar("n", 255)
val x = reference("x", B).nullable()
}
object B : IntIdTable("b") {
val i = varchar("m", 255)
val y = integer("y")
}
fun main() {
connectToDatabase()
transaction {
SchemaUtils.createMissingTablesAndColumns(A, B)
A.select { A.x eq 1 }
}
}
我希望它运行的等效 sql 是:
select * from test.a as a where a.x = 1;