sorry if this is a newb question, but I can't seem...
# exposed
j
sorry if this is a newb question, but I can't seem to track down a fix. I'm trying to add addLogger(StdOutSqlLogger) but I'm getting "unresolved reference" on addLogger because the type of StdOutSqlLogger "CompositeSqlLogger" does not match addLogger's receiver type of SqlLogger.
I have found a fix of sorts, but not exactly what I was hoping. I have a function to wrap queries in a transaction:
Copy code
suspend fun <T> dbQuery(block: suspend () -> T): T =
        newSuspendedTransaction(<http://Dispatchers.IO|Dispatchers.IO>) { block()}
but when I called
Copy code
query {
  addLogger(StdOutSqlLogger)
  Articles.select {....}
}
I get a receiver type mismatch error. When I do
Copy code
suspend fun <T> dbQuery(block: suspend () -> T): T =
        newSuspendedTransaction(<http://Dispatchers.IO|Dispatchers.IO>) {
            addLogger(StdOutSqlLogger)
            block()
        }
I don't get the error. Is there a way to add the logger only to certain queries?
a
dbQuery
should take a parameter of
Transaction.()
I think
e.g
suspend Transaction.() -> T
j
Oh of course! Thanks @AdamW
🤝 1