Coverage Summary for Class: CharacterQueries (com.javiersc.kaari.samples.strategies.internal)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
CharacterQueries |
0%
(0/6)
|
|
0%
(0/9)
|
0%
(0/62)
|
CharacterQueries$insert$1 |
0%
(0/1)
|
|
0%
(0/2)
|
0%
(0/10)
|
CharacterQueries$insert$2 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/4)
|
CharacterQueries$selectAll$1 |
0%
(0/1)
|
|
0%
(0/3)
|
0%
(0/13)
|
CharacterQueries$selectAll$2 |
0%
(0/1)
|
|
0%
(0/3)
|
0%
(0/5)
|
CharacterQueries$selectById$1 |
0%
(0/1)
|
|
0%
(0/3)
|
0%
(0/13)
|
CharacterQueries$selectById$2 |
0%
(0/1)
|
|
0%
(0/3)
|
0%
(0/5)
|
CharacterQueries$SelectByIdQuery |
0%
(0/5)
|
|
0%
(0/7)
|
0%
(0/52)
|
CharacterQueries$SelectByIdQuery$execute$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/6)
|
Total |
0%
(0/18)
|
|
0%
(0/32)
|
0%
(0/170)
|
package com.javiersc.kaari.samples.strategies.`internal`
import app.cash.sqldelight.Query
import app.cash.sqldelight.TransacterImpl
import app.cash.sqldelight.db.QueryResult
import app.cash.sqldelight.db.SqlCursor
import app.cash.sqldelight.db.SqlDriver
import kotlin.Any
import kotlin.String
import kotlin.Unit
public class CharacterQueries(
driver: SqlDriver,
) : TransacterImpl(driver) {
public fun <T : Any> selectById(id: String, mapper: (id: String, name: String) -> T): Query<T> =
SelectByIdQuery(id) { cursor ->
mapper(
cursor.getString(0)!!,
cursor.getString(1)!!
)
}
public fun selectById(id: String): Query<CharacterEntity> = selectById(id) { id_, name ->
CharacterEntity(
id_,
name
)
}
public fun <T : Any> selectAll(mapper: (id: String, name: String) -> T): Query<T> =
Query(-1394299015, arrayOf("CharacterEntity"), driver, "character.sq", "selectAll", """
|SELECT *
|FROM CharacterEntity
""".trimMargin()) { cursor ->
mapper(
cursor.getString(0)!!,
cursor.getString(1)!!
)
}
public fun selectAll(): Query<CharacterEntity> = selectAll { id, name ->
CharacterEntity(
id,
name
)
}
public fun insert(id: String, name: String): Unit {
driver.execute(-427466043, """
|INSERT INTO CharacterEntity(id, name)
|VALUES (?, ?)
""".trimMargin(), 2) {
bindString(0, id)
bindString(1, name)
}
notifyQueries(-427466043) { emit ->
emit("CharacterEntity")
}
}
private inner class SelectByIdQuery<out T : Any>(
public val id: String,
mapper: (SqlCursor) -> T,
) : Query<T>(mapper) {
public override fun addListener(listener: Query.Listener): Unit {
driver.addListener(listener, arrayOf("CharacterEntity"))
}
public override fun removeListener(listener: Query.Listener): Unit {
driver.removeListener(listener, arrayOf("CharacterEntity"))
}
public override fun <R> execute(mapper: (SqlCursor) -> R): QueryResult<R> =
driver.executeQuery(-273555206, """SELECT * FROM CharacterEntity WHERE id = ?""", mapper, 1)
{
bindString(0, id)
}
public override fun toString(): String = "character.sq:selectById"
}
}