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

Fix converting xml to record type with rest type and required fields #26

Merged
merged 8 commits into from
Aug 2, 2024

Conversation

prakanth97
Copy link
Contributor

Purpose

Fixes: #6659


public function main() returns error? {
    string xmlStr = string `
    <Data>
        <field2>
            <str2>2</str2>
            <str1>1</str1>
        </field2>
    </Data>
    `;
    record {|
        record {
            string str1;
        } field2;
    |} rec = check xmldata:parseString(xmlStr);
}

In the above case issue is element str1 is convert to anydata (int runtime value) instead of string. This is due to the all the elements after str2 convert to the rest type. In this PR we have fixed this wrong behaviour.

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@prakanth97 prakanth97 requested a review from hasithaa as a code owner July 4, 2024 04:56
@prakanth97
Copy link
Contributor Author

This PR depends on #20.

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 82.69231% with 9 lines in your changes missing coverage. Please review.

Project coverage is 86.46%. Comparing base (5173362) to head (a32e34e).
Report is 51 commits behind head on main.

Files Patch % Lines
...io/ballerina/lib/data/xmldata/utils/DataUtils.java 50.00% 3 Missing and 3 partials ⚠️
...a/io/ballerina/lib/data/xmldata/xml/XmlParser.java 92.50% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #26      +/-   ##
============================================
+ Coverage     85.92%   86.46%   +0.53%     
- Complexity      524      556      +32     
============================================
  Files            22       25       +3     
  Lines          2281     2416     +135     
  Branches        513      529      +16     
============================================
+ Hits           1960     2089     +129     
+ Misses          195      187       -8     
- Partials        126      140      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@prakanth97 prakanth97 merged commit a1bcdd4 into ballerina-platform:main Aug 2, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Class cast error for data.xmldata where expected type is a recored nested to an open record
2 participants