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

Fix logging for streaming and updateMany #2064

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

jatcwang
Copy link
Collaborator

@jatcwang jatcwang commented Jul 17, 2024

Introduces three new functions in the high level API for Connection (doobie.hi.HC).

Fixes #533, #1888

These helpers offer a few improvements:

  • Logging support
  • Handle and log exceptions throw during the PreparedStatement creation (Some JDBC drivers do this if the table doesn't exist)
  • A slighly simpler "flat" API for anyone that wants to customize their query

executeWithResultSet

This is a generalization for any query that executes a PreparedStatement and processes a ResultSet. This covers two cases:

  • A normal select query (JDBC's executeQuery)
  • An update which generates returned rows (i.e. RETURNING / .executeUpdate + .getGeneratedKeys)

All query methods like Query#to and Update#withUniqueGeneratedKeys have switched to use this internally.

executeWithoutResultSet

Similar to executeWithResultSet but for queries that doesn't need to process a ResultSet (i.e. simple updates).

Methods like Update's updateMany, update have switched to use this internally

stream

This will be replacing the existing stream method (which is currently deprecated because it doesn't support logging)

Query#stream and all the Update#withGeneratedKeys* have switched to this internally.

Further improvements can probably be made on top of these methods so users don't need to construct LoggingInfo themselves.

@jatcwang jatcwang merged commit 9e978b4 into main Jul 19, 2024
12 checks passed
@jatcwang jatcwang deleted the fix_logging_for_updateMany_and_streaming branch July 19, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

withGeneratedKeys & transaction statements missing from logs
1 participant