LogHandler isn't used when query is converted to a Stream
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 379
- Avg merge
- 14m
- Merged PRs (30d)
- 8
Description
object Repo {
implicit val printlnLogHandler = LogHandler(println)
val query: Query0[String] = sql"select name from person".toQuery[String]
def asStream: fs2.Stream[ConnectionIO, String] = query.stream
def asVector: ConnectionIO[Vector[String]] = query.to[Vector]
}
Repo.asVector.transact(transactor).unsafeRunSync() // produces log output
Repo.asVector.transact(transactor).compile.toVector.unsafeRunSync() // produces no log output
In Query, when we call to[Vector], we invoke the logging executeQuery:
def to[F[_]](a: A)(implicit cbf: CanBuildFrom[Nothing, B, F[B]]): ConnectionIO[F[B]] =
HC.prepareStatement(sql)(HPS.set(ai(a)) *> executeQuery(a, HRS.buildMap[F,O,B](ob)))
but the .stream path loses the logging executeQuery and uses HPS.executeQuery instead.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Query's stream implementation and compare it with the to[Vector] path shown in the issue, focusing on executeQuery and HPS.executeQuery. Reproduce the Scala example with Repo.asStream and Repo.asVector, then verify that streaming produces the same LogHandler output as the collection path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100