r2dbc / r2dbc-spi

Service Provider Interface for R2DBC Implementations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add sql to R2DBC exception hierarchy

mp911de opened this issue · comments

Feature Request

Is your feature request related to a problem? Please describe

When running SQL statements that terminate with an exception, it is difficult to determine what specific SQL statement has lead to the exception. While calling code can somewhat reason about it, it would make sense to attach the offending SQL statement to the actual exception.

Describe the solution you'd like

Introduce a final String sql field and getSql method to R2dbcException that can be nullable. Retrofit R2dbcBadGrammarException.offendingSql to remove the field and redirect getOffendingSql() to R2dbcException.getSql().

Looks to be a valuable addition to the SPI.

Could the JavaDocs of Statement.execute() and Batch.execute() specify that an R2dbcException emitted by the returned Publisher is guaranteed to return a non-null String when getSql() is invoked?