mybatis / mybatis-3

MyBatis SQL mapper framework for Java
http://mybatis.github.io/mybatis-3/
Apache License 2.0
19.55k stars 12.74k forks source link

fix : Enhancing Readability and Reliability with isEmpty Check #3143

Closed dukbong closed 2 months ago

dukbong commented 2 months ago

This PR aims to enhance readability and reliability by utilizing the isEmpty method generated from the ResultLoaderMap. By considering not only null but also whether the length is zero in the context flow, it prevents unnecessary advancement to the next block.

coveralls commented 2 months ago

Coverage Status

coverage: 87.159% (-0.009%) from 87.168% when pulling fad45e24d225746ab14b698840822ae56ce54b75 on dukbong:recommend into 7ae38a258317cd9cccc0a6106686a676fdfc1d8e on mybatis:master.

dukbong commented 2 months ago

Thank you for the PR, @dukbong .

Please see the comments.


@harawata I understand your concern about wanting to clarify the condition, but upon further reflection, it seems there's no need to change it.

List<PendingRelation> parents = pendingRelations.get(parentKey);
    if (parents != null && !parents.isEmpty()) {
      for (PendingRelation parent : parents) {
        if (rowValue != null) {
          linkObjects(parent.metaObject, parent.propertyMapping, rowValue);
        }
      }
    }

I wanted to make the condition clearer like this, but upon reconsideration, I'm not sure if it's really necessary. I'll make sure to think more carefully before submitting PRs in the future.