Coverage Summary for Class: SqlClickSoundsQueries (com.vsevolodganin.clicktrack.storage)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
SqlClickSoundsQueries |
0%
(0/18)
|
|
0%
(0/36)
|
0%
(0/145)
|
SqlClickSoundsQueries$GetByIdQuery |
0%
(0/6)
|
|
0%
(0/10)
|
0%
(0/55)
|
Total |
0%
(0/24)
|
|
0%
(0/46)
|
0%
(0/200)
|
package com.vsevolodganin.clicktrack.storage
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.Long
import kotlin.String
public class SqlClickSoundsQueries(
driver: SqlDriver,
) : TransacterImpl(driver) {
public fun <T : Any> getAll(mapper: (id: Long, serializedValue: String) -> T): Query<T> =
Query(-1_177_780_193, arrayOf("ClickSounds"), driver, "SqlClickSounds.sq", "getAll",
"SELECT ClickSounds.id, ClickSounds.serializedValue FROM ClickSounds") { cursor ->
mapper(
cursor.getLong(0)!!,
cursor.getString(1)!!
)
}
public fun getAll(): Query<ClickSounds> = getAll { id, serializedValue ->
ClickSounds(
id,
serializedValue
)
}
public fun <T : Any> getById(id: Long, mapper: (id: Long, serializedValue: String) -> T): Query<T>
= GetByIdQuery(id) { cursor ->
mapper(
cursor.getLong(0)!!,
cursor.getString(1)!!
)
}
public fun getById(id: Long): Query<ClickSounds> = getById(id) { id_, serializedValue ->
ClickSounds(
id_,
serializedValue
)
}
/**
* @return The number of rows updated.
*/
public fun insert(serializedValue: String): QueryResult<Long> {
val result = driver.execute(-1_112_205_203,
"""INSERT INTO ClickSounds (serializedValue) VALUES (?)""", 1) {
bindString(0, serializedValue)
}
notifyQueries(-1_112_205_203) { emit ->
emit("ClickSounds")
}
return result
}
/**
* @return The number of rows updated.
*/
public fun update(serializedValue: String, id: Long): QueryResult<Long> {
val result = driver.execute(-767_259_011,
"""UPDATE ClickSounds SET serializedValue = ? WHERE id = ?""", 2) {
bindString(0, serializedValue)
bindLong(1, id)
}
notifyQueries(-767_259_011) { emit ->
emit("ClickSounds")
}
return result
}
/**
* @return The number of rows updated.
*/
public fun removeById(id: Long): QueryResult<Long> {
val result = driver.execute(997_016_106, """DELETE FROM ClickSounds WHERE id = ?""", 1) {
bindLong(0, id)
}
notifyQueries(997_016_106) { emit ->
emit("ClickSounds")
}
return result
}
private inner class GetByIdQuery<out T : Any>(
public val id: Long,
mapper: (SqlCursor) -> T,
) : Query<T>(mapper) {
override fun addListener(listener: Query.Listener) {
driver.addListener("ClickSounds", listener = listener)
}
override fun removeListener(listener: Query.Listener) {
driver.removeListener("ClickSounds", listener = listener)
}
override fun <R> execute(mapper: (SqlCursor) -> QueryResult<R>): QueryResult<R> =
driver.executeQuery(2_143_560_980,
"""SELECT ClickSounds.id, ClickSounds.serializedValue FROM ClickSounds WHERE id = (?)""",
mapper, 1) {
bindLong(0, id)
}
override fun toString(): String = "SqlClickSounds.sq:getById"
}
}