ResultQuery

class ResultQuery @PublishedApi constructor(val query: RunnableQuery<*>)

The same query, with every terminal handing back a DataResult instead of throwing.

Reached by RunnableQuery.asResult and equivalent to wrapping the call in dbResult - the same boundary, the same classification, the same failures let through. What it changes is only the shape at the call site: a chain stays a chain rather than being indented inside a lambda, which is worth something once a builder has put four calls in front of the terminal.

val senators = db.rawQuery("SELECT id, cognomen FROM senate WHERE province_id = @p")
.asResult()
.fetchObjects<Senator>("p" to 7)

dbResult { } is still what to reach for around anything wider than one query - a whole unit of work, a db.execute { } block, a RawQuery.execute(). Around a transaction reach for neither: use transactionResult, which rolls back on a failure rather than committing over one.

Constructors

Link copied to clipboard
internal constructor(query: RunnableQuery<*>)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
inline fun <T> fetchField(params: Map<String, Any?> = emptyMap()): DataResult<T>
inline fun <T> fetchField(vararg params: Pair<String, Any?>): DataResult<T>

As RunnableQuery.fetchField - a non-nullable T over a missing row is still thrown.

Link copied to clipboard
inline fun <T> fetchFields(params: Map<String, Any?> = emptyMap()): DataResult<List<T>>
inline fun <T> fetchFields(vararg params: Pair<String, Any?>): DataResult<List<T>>
Link copied to clipboard
inline fun <T> fetchFieldStrict(params: Map<String, Any?> = emptyMap()): DataResult<T>
inline fun <T> fetchFieldStrict(vararg params: Pair<String, Any?>): DataResult<T>
Link copied to clipboard
inline fun <T : Any> fetchObject(params: Map<String, Any?> = emptyMap()): DataResult<T?>
inline fun <T : Any> fetchObject(vararg params: Pair<String, Any?>): DataResult<T?>
Link copied to clipboard
inline fun <T : Any> fetchObjects(params: Map<String, Any?> = emptyMap()): DataResult<List<T>>
inline fun <T : Any> fetchObjects(vararg params: Pair<String, Any?>): DataResult<List<T>>
Link copied to clipboard
inline fun <T : Any> fetchObjectStrict(params: Map<String, Any?> = emptyMap()): DataResult<T>
inline fun <T : Any> fetchObjectStrict(vararg params: Pair<String, Any?>): DataResult<T>

As RunnableQuery.fetchObjectStrict - which means a missing row is still thrown, not returned.

Link copied to clipboard
fun fetchRow(params: Map<String, Any?> = emptyMap()): DataResult<Row?>
fun fetchRow(vararg params: Pair<String, Any?>): DataResult<Row?>
Link copied to clipboard
fun fetchRows(params: Map<String, Any?> = emptyMap()): DataResult<List<Row>>
fun fetchRows(vararg params: Pair<String, Any?>): DataResult<List<Row>>
Link copied to clipboard
fun fetchRowStrict(params: Map<String, Any?> = emptyMap()): DataResult<Row>
fun fetchRowStrict(vararg params: Pair<String, Any?>): DataResult<Row>

As RunnableQuery.fetchRowStrict - which means a missing row is still thrown, not returned.

Link copied to clipboard
inline fun <T> forEachField(params: Map<String, Any?> = emptyMap(), fetchSize: Int, crossinline block: (T) -> Unit): DataResult<Unit>
inline fun <T> forEachField(vararg params: Pair<String, Any?>, fetchSize: Int, crossinline block: (T) -> Unit): DataResult<Unit>
Link copied to clipboard
inline fun <T : Any> forEachObject(params: Map<String, Any?> = emptyMap(), fetchSize: Int, crossinline block: (T) -> Unit): DataResult<Unit>
inline fun <T : Any> forEachObject(vararg params: Pair<String, Any?>, fetchSize: Int, crossinline block: (T) -> Unit): DataResult<Unit>
Link copied to clipboard
fun forEachRow(params: Map<String, Any?> = emptyMap(), fetchSize: Int, block: (Row) -> Unit): DataResult<Unit>
fun forEachRow(vararg params: Pair<String, Any?>, fetchSize: Int, block: (Row) -> Unit): DataResult<Unit>
Link copied to clipboard
fun toSql(): String

As RunnableQuery.toSql - the rendered SQL, for embedding in a larger statement or for a log line.

Link copied to clipboard
fun update(params: Map<String, Any?> = emptyMap()): DataResult<Long>
fun update(vararg params: Pair<String, Any?>): DataResult<Long>