You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fesod.apache.org by "CodeMan-cmd (via GitHub)" <gi...@apache.org> on 2026/09/23 01:28:26 UTC

[I] [Bug] Column include/exclude drops or keeps the wrong columns for field names like xRealIp [fesod]

CodeMan-cmd opened a new issue, #1129:
URL: https://github.com/apache/fesod/issues/1129

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fesod/issues) and found nothing similar.
   
   
   ### Fesod version
   
   2.1.0-incubating (main branch, commit 4e3f3aa)
   
   ### JDK version
   
   Temurin 1.8.0_472
   
   ### Operating system
   
   Windows 10 (amd64)
   
   ### Steps To Reproduce
   
   Field names that start with a lower case letter followed by an upper case letter, for example `xRealIp` or `pName`, are common in generated DTOs (a `X_REAL_IP` column converted to camel case).
   
   Data class:
   
   ```java
   public class CamelCaseFieldData {
       @ExcelProperty("name")
       private String name;
       @ExcelProperty("xRealIp")
       private String xRealIp;
       @ExcelProperty("pName")
       private String pName;
   }
   ```
   
   Test code:
   
   ```java
   File file = new File("camel.xlsx");
   FesodSheet.write(file, CamelCaseFieldData.class)
           .includeColumnFieldNames(Arrays.asList("name", "xRealIp", "pName"))
           .sheet()
           .doWrite(data());
   List&lt;Map&lt;Integer, String&gt;&gt; dataMap = FesodSheet.read(file).sheet().doReadSync();
   // only one column is written, the others are silently dropped
   ```
   
   A test method with this content is added by the PR that fixes it: it fails on the current main branch and passes with the fix.
   
   ### Current Behavior
   
   `includeColumnFieldNames(Arrays.asList("name", "xRealIp", "pName"))` writes 1 column instead of 3, the xRealIp and pName columns are dropped from the file. `excludeColumnFieldNames(Arrays.asList("xRealIp"))` keeps the xRealIp column.
   
   Cause: `ClassUtils.doDeclaredFields` filters with `writeHolder.ignore(field.getFieldName(), ...)`, and `FieldWrapper` getFieldName is the name kept by the cglib bean map of the field (see `FieldUtils` resolveCglibFieldName), which is `XRealIp` for the field `xRealIp`. `AbstractWriteHolder` ignore compares that name with the field names configured by the user, so the comparison only works when the cglib name equals the Java field name, which is the case for names like `column1` or `name`, but not for names like `xRealIp` or `pName`.
   
   `ClassUtils.resortField` has the same problem: it looks the order of a column up by `field.getFieldName()` and assigns a position to every configured name, so an unknown name leaves a hole and shifts the following columns when `orderByIncludeColumn(true)` is used.
   
   ### Expected Behavior
   
   `includeColumnFieldNames(Arrays.asList("name", "xRealIp", "pName"))` writes all three columns, `excludeColumnFieldNames(Arrays.asList("xRealIp"))` writes `name` and `pName` only.
   
   Filtering by field name must use the Java field name, which is the name the user configures and the name used when reading the file back, and an unknown name in the include list must not hold a column position.
   
   ### Anything else?
   
   Related EasyExcel issue, the same code exists there: https://github.com/alibaba/easyexcel/issues/4110
   
   I have a fix ready in a fork, it also adds unit tests: https://github.com/CodeMan-cmd/fesod/tree/fix-include-exclude-camel-case-field-name (PR follows).
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org


Re: [I] [Bug] Column include/exclude drops or keeps the wrong columns for field names like xRealIp [fesod]

Posted by "CodeMan-cmd (via GitHub)" <gi...@apache.org>.
CodeMan-cmd commented on issue #1129:
URL: https://github.com/apache/fesod/issues/1129#issuecomment-5787397287

   PR that fixes this: #1130
   
   Summary of the change: use the Java field name for the include/exclude check in `ClassUtils#doDeclaredFields`, look the column order up by Java field name in `ClassUtils#resortField`, and skip a name that is not a field of the class so that it does not hold a column position.
   
   Verification on my machine with Temurin 1.8.0_472, before and after the change:
   
   * new test class `CamelCaseFieldDataTest`: 15 of 21 cases fail before the change, all 21 pass after it
   * `./mvnw clean package -B -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet`: 937 tests, 0 failures
   * `./mvnw spotless:check`: Build success


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fesod.apache.org
For additional commands, e-mail: commits-help@fesod.apache.org