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

[2201.8.x] Fix value conversion error for record creation with special characters #41751

Conversation

HindujaB
Copy link
Contributor

Purpose

$subject

Fixes #41633

Approach

As we use the decoded identifiers in the value conversions, the generated record value creators should have the same representation in the switch cases. This PR fixes it by using the Utils.unescapeBallerina() API. The issue happens for typedef name as well.

Samples

import ballerina/io;

public type Copybook record {
    DFH\-COMMAREA DFH\-COMMAREA?;
};

public type DFH\-COMMAREA record {
    record {
        string MI\-HDR\-VERSION?;
        string MI\-HDR\-MSGID?;
        string MI\-HDR\-LOGGINGID?;
        record {
            string MI\-HDR\-REPLYQMGR?;
        }[2] MI\-HDR\-REPLYSTACK?;
    } BROKER\-MESSAGE\-AREA?;
};

public function main() returns error? {
    string s = string `{
    "DFH-COMMAREA": {
        "BROKER-MESSAGE-AREA": {
            "MI-HDR-VERSION": "2",
            "MI-HDR-MSGID":"3238763233323598798798712321187612",
            "MI-HDR-LOGGINGID": "Z5118761-Z"
        }
    }
    }`;
    json rec = checkpanic value:fromJsonString(s);
    map<json> mapJson = check rec.ensureType();
    Copybook dfhcommarea = check mapJson.cloneWithType();
    io:println(dfhcommarea.DFH\-COMMAREA?.BROKER\-MESSAGE\-AREA);
}

Remarks

Related to #41633

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bcd2eaf) 76.35% compared to head (5a477ba) 76.36%.
Report is 1 commits behind head on 2201.8.x.

Additional details and impacted files
@@             Coverage Diff             @@
##             2201.8.x   #41751   +/-   ##
===========================================
  Coverage       76.35%   76.36%           
- Complexity      52561    52562    +1     
===========================================
  Files            2880     2880           
  Lines          198779   198778    -1     
  Branches        25827    25826    -1     
===========================================
+ Hits           151782   151790    +8     
+ Misses          38639    38631    -8     
+ Partials         8358     8357    -1     

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

Copy link
Contributor

@warunalakshitha warunalakshitha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@warunalakshitha warunalakshitha merged commit ce1eb3f into ballerina-platform:2201.8.x Nov 23, 2023
6 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.

2 participants