groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akapps <...@git.apache.org>
Subject [GitHub] groovy pull request #586: GROOVY-8288 executeBatch() should not be called wi...
Date Tue, 15 Aug 2017 07:54:49 GMT
Github user akapps commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/586#discussion_r133134481
  
    --- Diff: subprojects/groovy-sql/src/main/java/groovy/sql/BatchingStatementWrapper.java
---
    @@ -83,8 +83,15 @@ public void clearBatch() throws SQLException {
         }
     
         public int[] executeBatch() throws SQLException {
    -        int[] lastResult = delegate.executeBatch();
    -        processResult(lastResult);
    +        if (batchCount > 0) {
    +            int[] lastResult = delegate.executeBatch();
    +            processResult(lastResult);
    +        }
    +        else if (results.isEmpty()) {
    +            log.warning("Nothing has been added to batch");
    +            // we let the JDBC provider decide how to handle an empty batch execution
    +            return delegate.executeBatch();
    +        }
    --- End diff --
    
    This "else if" is not really elegant for such a particular case...
    I could have done `if (batchCount > 0 || results.isEmpty())` in the first condition,
but I thought it made the intention unreadable.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message