typelevel / typelevel/doobie

LogHandler isn't used when query is converted to a Stream

Open
#772 1 comment 4 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.