[ 
https://issues.apache.org/jira/browse/GROOVY-12296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18108113#comment-18108113
 ] 

ASF GitHub Bot commented on GROOVY-12296:
-----------------------------------------

codecov-commenter commented on PR #2832:
URL: https://github.com/apache/groovy/pull/2832#issuecomment-5417976900

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2832?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 70.6471%. Comparing base 
([`47f3b75`](https://app.codecov.io/gh/apache/groovy/commit/47f3b75e70158a5d8099fd26be0b3140b703d507?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`59f78f3`](https://app.codecov.io/gh/apache/groovy/commit/59f78f31bbb70544dd44b6a059bb583f64b3cb34?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/2832/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2832?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2832        +/-   ##
   ==================================================
   - Coverage     70.6514%   70.6471%   -0.0043%     
   + Complexity      36525      36523         -2     
   ==================================================
     Files            1571       1571                
     Lines          133962     133963         +1     
     Branches        24690      24690                
   ==================================================
   - Hits            94646      94641         -5     
   - Misses          30800      30803         +3     
   - Partials         8516       8519         +3     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2832?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...roovy-csv/src/main/java/groovy/csv/CsvBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/2832?src=pr&el=tree&filepath=subprojects%2Fgroovy-csv%2Fsrc%2Fmain%2Fjava%2Fgroovy%2Fcsv%2FCsvBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNzdi9zcmMvbWFpbi9qYXZhL2dyb292eS9jc3YvQ3N2QnVpbGRlci5qYXZh)
 | `65.2174% <ø> (ø)` | |
   | 
[...roovy-csv/src/main/java/groovy/csv/CsvSlurper.java](https://app.codecov.io/gh/apache/groovy/pull/2832?src=pr&el=tree&filepath=subprojects%2Fgroovy-csv%2Fsrc%2Fmain%2Fjava%2Fgroovy%2Fcsv%2FCsvSlurper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNzdi9zcmMvbWFpbi9qYXZhL2dyb292eS9jc3YvQ3N2U2x1cnBlci5qYXZh)
 | `83.6956% <100.0000%> (+0.1792%)` | :arrow_up: |
   
   ... and [4 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2832/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> CsvBuilder: toCsv(data, type) emits columns in alphabetical rather than 
> declaration order
> -----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12296
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12296
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Priority: Major
>
> {{CsvBuilder.toCsv(data, type)}} derives its schema via Jackson's 
> {{CsvMapper.schemaFor(type)}}, which emits columns in Jackson's introspected 
> property order — alphabetical — rather than declaration order:
> {code:groovy}
> record Person(String name, int age, String city) {}
> def people = [new Person('Alice', 30, 'Perth')]
> println groovy.csv.CsvBuilder.toCsv(people, Person)
> {code}
> produces:
> {noformat}
> age,city,name
> 30,Perth,Alice
> {noformat}
> The same applies to plain classes, not just records. Note that the map-based 
> {{toCsv(Collection<Map>)}} overload behaves differently — it respects the 
> insertion order of the first map's keys.
> This is not documented: the "Typed writing" section of the user guide and the 
> {{toCsv(data, type)}} javadoc say nothing about column order. The doc/test 
> example ({{Product}} with fields {{name}}, {{price}}) is coincidentally 
> already alphabetical, so the current tests pass regardless of ordering 
> behavior.
> *Workaround (verified):* annotate the type with {{@JsonPropertyOrder}}:
> {code:groovy}
> @JsonPropertyOrder(['name', 'age', 'city'])
> record Person(String name, int age, String city) {}
> {code}
> produces {{name,age,city}} as expected.
> *Possible resolutions:*
> # For records, build the schema from {{type.getRecordComponents()}} 
> (declaration order) when no {{@JsonPropertyOrder}} is present.
> # Document the current behavior and the {{@JsonPropertyOrder}} workaround in 
> the "Typed writing" section of the user guide, using an example whose fields 
> are not already in alphabetical order so the behavior is actually exercised 
> by the doc tests.
> Since the module is still {{@Incubating}}, option 1 can be adopted without 
> compatibility concerns.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to