Skip to content

Conversation

@bog-walk
Copy link
Member

Description

Summary of the change: Remove TODOs that have already been addressed or that don't require a fix.

Detailed description:

  • What:
  1. All usages of SQLException in core already removed when V1 merged
  2. More details on ExposedSQLException + ExposedR2dbcException in Slack channel
  3. JdbcResult already contains next() and implements RowApi.getObject()
  4. JDBC tests are being properly checked after R2DBC tests in CI now, and all green
  5. There seems to be no way to avoid overload ambiguity with Flow.map()
  6. Repomix is used for ... Junie? But only with exposed-r2dbc?
  7. No known issue of generated key values not being returned by prepared statement (misunderstanding TODO?)
  8. Safer to leave decision to fail to SPI rowsUpdated as throw behavior changes depending on whether result is empty

Type of Change

Please mark the relevant options with an "X":

  • Other - TODO cleanup

Comment on lines -698 to -697
// TODO check for all `throw SQLException` in the code?
// TODO could some of them replaced wit other errors?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No usage of SQLException or ExposedSQLException in core. Only in exposed-jdbc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use SQL Exception instead of error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e5l I would hesitate to do this for 3 reasons:

  1. java.sql.SQLException seems very JDBC-specific. It never comes up as part of the R2DBC spi. I at least looked through H2+PG r2dbc repos and they never throw this exception (they only catch and re-purpose). So it feels odd to use it in exposed-core now with driver separation
  2. TransactionManager logic has different behavior based on type of exception caught. SQLException is always caught first (in exposed-jdbc) and triggers (potentially) more attempts to execute the same statement, whereas an ISE thrown by Exposed will not trigger multiple runs.
  3. There's currently no instance of Exposed throwing such an exception; we catch any thrown naturally by the DB and wrap as ExposedSQLException. So currently there's a clear distinction between exceptions thrown by DB and exceptions thrown by Exposed, but if we started mimicking DB SQLException, wouldn't that blur?

Comment on lines -13 to -14
// TODO Discuss keeping this in core (not used here) & package mismatch
// Consider changing package if moving to jdbc module
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More details in Slack, if this needs to be reconsidered

Comment on lines -19 to -20
// TODO should we allow users to use ResultApi manually with possibility to call next()/getObject() in the code?
// TODO Or the `mapRows` is the only right way to use it?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you expand down, JdbcResult at some point was extended to provide next() functionality and already implements RowApi.getObject(). So users do have a choice to manually iterate over results or use mapRows().

User.name like stringLiteral("Hich%").upperCase()
}.map { it[User.name] }
.toList() // TODO this is the only unmapped Iterable <-> Flow operation; impossible?
.toList()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of this TODO was to have a seamless duplicate of the JDBC test, in the event they could be merged or reused to a certain degree in the future, meaning the ability to call Flow<T>.map { } and return List<T> without always needing to chain .toList().

I tried many overload variations, dummy parameters, and even kotlin.internal.HidesMembers, and could not avoid getting an overload ambiguity resolution error.
If there are any suggestions, or preference to keep this, let me know.

compileOnly(libs.postgre)
compileOnly(libs.r2dbc.postgresql)
}
// TODO confirm use of repomix.config.json +/- remove?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e5l If I recall correctly, you mentioned that the file exposed-r2dbc/repomix.config.json was added for Junie?
But it was only added to that single module, not to any others?

Please confirm again whether the file should be left alone or removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to drop it

Comment on lines -58 to +62
// Todo relies on rowsUpdated throwing ISE if already consumed; should we fail earlier as in mapRows()?
/** Returns a Flow containing the number of rows updated by executing a statement. */
/**
* Returns a Flow containing the number of rows updated by executing a statement.
*
* @throws IllegalStateException If the result has already been consumed by another flow operation.
*/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran tests to confirm the behavior and found the following:

  • If a statement that is meant to update rows is executed, like INSERT RETURNING, and the result is consumed first by mapRows(), then SPI rowsUpdated throws ISE.
  • If a SELECT statement is executed and the result is consumed with mapRows(), then using rowsUpdated doesn't throw; it will just return an empty flow. Which makes sense I guess because no rows were meant to be updated.

So I'm hesitant to have us fail early instead, only based on whether mapRows() was called or not, given that the result would not be equal to the underlying behavior of the SPI rowsUpdated.
I'm leaving that decision to the SPI and just updated the KDocs instead.

@bog-walk bog-walk requested review from e5l and obabichevjb July 10, 2025 00:47
Comment on lines -698 to -697
// TODO check for all `throw SQLException` in the code?
// TODO could some of them replaced wit other errors?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use SQL Exception instead of error?

@bog-walk bog-walk force-pushed the bog-walk/remove-fixed-todos branch from bd03b90 to d271bcd Compare July 14, 2025 23:49
@bog-walk bog-walk merged commit 9f7f0c7 into main Jul 15, 2025
6 checks passed
@bog-walk bog-walk deleted the bog-walk/remove-fixed-todos branch July 15, 2025 00:48
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

Successfully merging this pull request may close these issues.

4 participants