Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LogHandler does not capture streaming queries or bulk updates #1888

Open
soujiro32167 opened this issue Jun 30, 2023 · 5 comments
Open

LogHandler does not capture streaming queries or bulk updates #1888

soujiro32167 opened this issue Jun 30, 2023 · 5 comments
Milestone

Comments

@soujiro32167
Copy link

Scala: 2.13.11
Doobie: 1.0.0-RC4
Postgres: 14.3

Repro:

import cats.effect.{ExitCode, IO, IOApp}
import doobie.implicits.*

object Repro extends IOApp{
  val xa = Transactor.fromDriverManager[IO](
    driver = "org.postgresql.Driver",
    url = "jdbc:postgresql:postgres",
    user = "postgres",
    password = "postgres",
    logHandler = Some(LogHandler.jdkLogHandler)
  )

  def run(args: List[String]): IO[ExitCode] = for {
    _ <- sql"SELECT 1".query[Int].unique.transact(xa) // this gets logged
    _ <- sql"SELECT 1".query[Int].stream.compile.lastOrError.transact(xa) // this doesn't
    _ <- Update[Int]("SELECT ?").updateMany(List(1)).transact(xa) // this doesn't
  } yield ExitCode.Success
}
@satorg
Copy link

satorg commented Jun 30, 2023

I think it is related to (or maybe duplicates) #772.

@soujiro32167
Copy link
Author

😱

@jatcwang jatcwang modified the milestones: 1.0, 1.0-RC5 Jul 1, 2023
@soujiro32167
Copy link
Author

from #772 (comment)

It may be worthwhile to go ahead and add a Log constructor to each Free algebra so we can plumb this in from the bottom

It looks like RC3 did exactly that - there is now a PerformLogging in every algebra, so it seems. Anything I can help with?

@jatcwang
Copy link
Collaborator

For stream it shouldn't be too hard to plumb the SQL, args and label through. For updateMany it's a bit weirder but if we log only the first set of args then it'll work too (though imperfect)

@jatcwang
Copy link
Collaborator

jatcwang commented Nov 22, 2023

From #533, seems like withGeneratedKeys isn't logging either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants