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

Return null when applicable from getGeneratedKeys #2180

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Commits on Feb 28, 2024

  1. Return null when applicable from getGeneratedKeys

    Currently, there is no way to check if `getGeneratedKeys` returned `null`.  Instead, when trying to call `ResultSet.next()` a `NullPointerException` is thrown.
    
    This method [should return an empty `ResultSet` when there are no generated keys]( https://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#getGeneratedKeys--), but not all JDBC drivers do (like [Apache](https://github.com/apache/derby/blob/4253dcf4aa37dc64cf7235d494cd2f00f72e678a/java/org.apache.derby.client/org/apache/derby/client/am/ClientStatement.java#L271) [Derby](https://github.com/apache/derby/blob/4253dcf4aa37dc64cf7235d494cd2f00f72e678a/java/org.apache.derby.client/org/apache/derby/client/am/ClientStatement.java#L1378-L1394))  In these cases, I think the safest option is to return `null`, which can then be checked (and is checked in popular JDBC libraries [like JOOQ.](https://github.com/jOOQ/jOOQ/blob/181d838797d8238edd52576df6b7d3827cceb797/jOOQ/src/main/java/org/jooq/impl/AbstractDMLQuery.java#L1350-L1352))
    elpete authored Feb 28, 2024
    Configuration menu
    Copy the full SHA
    6bb7d87 View commit details
    Browse the repository at this point in the history