Hildebrandt Tobias
11/06/2024, 9:25 AM.deleteWhere
with eq
it says that it can't resolve eq
, and also does not offer any imports.
I have to manually add import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
to the imports.
Example:
override fun deleteEntries(productionStateId: ProductionStateId) = database.transaction {
ProductionStateEntryTable
.deleteWhere { ProductionStateEntryTable.productionStateId eq productionStateId.value }
}
Curiously, once I add the above import it points to the exact same spot when I follow the reference to SQLExpressionBuilder.kt
in org.jetbrains.exposed.sql.ISqlExpressionBuilder
Even the inspect for a "where eq" and a "deletewhere eq" are the exact same package, but when I remove the import above the
deleteWhere
stops working while the where
is unaffected.Chantal Loncle
11/06/2024, 3:43 PMdeleteWhere()
signature is set up differently, compared to update(where = {})
. To show this, for example, if you defined your own function to match, it would remove any resolution errors:
fun <T : Table> T.delete(
where: SqlExpressionBuilder.() -> Op<Boolean>,
limit: Int? = null,
): Int {
val query = DeleteStatement(this, SqlExpressionBuilder.where(), false, limit, emptyList())
return query.execute(TransactionManager.current()) ?: 0
}
// ... no resolution errors
MyTable.delete(where = { MyTable.id eq 1 })
> ... and also does not offer any imports.
Could you please confirm that this is with IntelliJ IDEA?
If you mouse over the error or Show Context Actions (Alt+Enter), do you not get a prompt to Import extension functions...
?Hildebrandt Tobias
11/06/2024, 4:05 PMChantal Loncle
11/06/2024, 4:39 PMHildebrandt Tobias
11/06/2024, 8:44 PMHildebrandt Tobias
11/06/2024, 8:52 PMChantal Loncle
11/12/2024, 1:04 AMHildebrandt Tobias
11/14/2024, 11:09 AMCXwudi
12/05/2024, 1:53 AMfun delete(id: Int): Boolean = Users.deleteWhere {
with(it) {
Users.id eq id
}
} > 0