dave08
01/10/2023, 11:46 AMString
... does that mean that it's also supported by Komapper?Toshihiro Nakamura
01/10/2023, 12:01 PMdave08
01/10/2023, 12:03 PMdave08
01/10/2023, 12:04 PMdave08
01/10/2023, 12:05 PMdave08
01/10/2023, 12:06 PMdave08
01/10/2023, 12:10 PMdave08
01/10/2023, 12:10 PMdave08
01/10/2023, 12:14 PMdave08
01/10/2023, 12:15 PMdave08
01/10/2023, 12:19 PMToshihiro Nakamura
01/10/2023, 12:31 PMdave08
01/10/2023, 12:35 PMdave08
01/10/2023, 12:37 PMdave08
01/10/2023, 12:39 PMdave08
01/10/2023, 12:48 PMdave08
01/10/2023, 12:48 PMToshihiro Nakamura
01/10/2023, 12:54 PMSo is there maybe a way to just wrap the jdbc implementation in the meantime?You can achieve this by implementing the
R2dbcDatabase
interface yourself.dave08
01/10/2023, 1:01 PMoverride fun <T> flowQuery(query: FlowQuery<T>): Flow<T> =
?Toshihiro Nakamura
01/10/2023, 1:09 PMQuery
interface.dave08
01/10/2023, 1:10 PMwithTransaction
?Toshihiro Nakamura
01/10/2023, 1:18 PMJdbcDatabase.withTransaction
. Note that JdbcDatabase manages transactions in ThreadLocal.dave08
01/10/2023, 1:19 PMCoroutineTransactionOperator
...dave08
01/10/2023, 1:23 PMclass JdbcR2dbcAdapter(val db: JdbcDatabase) : R2dbcDatabase {
override val config: R2dbcDatabaseConfig get() = TODO()
override fun <T> flowQuery(query: FlowQuery<T>): Flow<T> = flow {
val result = withContext(<http://Dispatchers.IO|Dispatchers.IO>) { db.runQuery(query as Query<T>) as Iterable<T> }
result.forEach { emit(it) }
}
override fun <T> flowQuery(block: QueryScope.() -> FlowQuery<T>): Flow<T> = flow {
val block = block as QueryScope.() -> Query<T>
val result = withContext(<http://Dispatchers.IO|Dispatchers.IO>) { db.runQuery(block) as Iterable<T> }
result.forEach { emit(it) }
}
override fun <R> flowTransaction(
transactionAttribute: TransactionAttribute,
transactionProperty: TransactionProperty,
block: suspend FlowCollector<R>.(FlowTransactionOperator) -> Unit
): Flow<R> {
TODO("Not yet implemented")
}
override suspend fun <T> runQuery(query: Query<T>): T = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
db.runQuery(query)
}
override suspend fun <T> runQuery(block: QueryScope.() -> Query<T>): T = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
db.runQuery(block)
}
override suspend fun <R> withTransaction(
transactionAttribute: TransactionAttribute,
transactionProperty: TransactionProperty,
block: suspend (CoroutineTransactionOperator) -> R
): R {
TODO("Not yet implemented")
}
}
dave08
01/10/2023, 1:25 PM<http://Dispatchers.IO|Dispatchers.IO>
pool should maybe be limited... but otherwise do you see any other problems with this implementation?dave08
01/10/2023, 1:25 PMIterable<T>
is right in the flowQuery implementations...