
org.jetbrains.exposed.sql.statements.DeleteStatement.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of exposed Show documentation
Show all versions of exposed Show documentation
Exposed, an ORM framework for Kotlin
package org.jetbrains.exposed.sql.statements
import org.jetbrains.exposed.sql.*
import java.sql.PreparedStatement
open class DeleteStatement(val table: Table, val where: Op? = null, val isIgnore: Boolean = false, val limit: Int? = null, val offset: Int? = null): Statement(StatementType.DELETE, listOf(table)) {
override fun PreparedStatement.executeInternal(transaction: Transaction): Int {
transaction.flushCache()
transaction.entityCache.removeTablesReferrers(listOf(table))
return executeUpdate()
}
override fun prepareSQL(transaction: Transaction): String =
transaction.db.dialect.functionProvider.delete(isIgnore, table, where?.let { QueryBuilder(true).append(it).toString() }, limit, transaction)
override fun arguments(): Iterable>> = QueryBuilder(true).run {
where?.toQueryBuilder(this)
listOf(args)
}
companion object {
fun where(transaction: Transaction, table: Table, op: Op, isIgnore: Boolean = false, limit: Int? = null, offset: Int? = null): Int
= DeleteStatement(table, op, isIgnore, limit, offset).execute(transaction) ?: 0
fun all(transaction: Transaction, table: Table): Int = DeleteStatement(table).execute(transaction) ?: 0
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy