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 value conversion error for inline record creation with special characters #41640

Merged

Conversation

HindujaB
Copy link
Contributor

@HindujaB HindujaB commented Nov 3, 2023

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.

Samples

import ballerina/io;

public type Copybook record {
    DFHCOMMAREA DFHCOMMAREA?;
};

public type DFHCOMMAREA 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 `{
    "DFHCOMMAREA": {
        "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.DFHCOMMAREA?.BROKER\-MESSAGE\-AREA);
}

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

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 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (62408d8) 76.68% compared to head (4c81b9e) 76.72%.
Report is 45 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #41640      +/-   ##
============================================
+ Coverage     76.68%   76.72%   +0.04%     
- Complexity    52671    52689      +18     
============================================
  Files          2880     2879       -1     
  Lines        198580   198657      +77     
  Branches      25801    25809       +8     
============================================
+ Hits         152282   152422     +140     
+ Misses        37876    37807      -69     
- Partials       8422     8428       +6     

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

@gabilang gabilang added the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Nov 10, 2023
@HindujaB HindujaB force-pushed the fix-record-special-char branch from 20c18d1 to d30752f Compare November 16, 2023 08:12
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

gabilang
gabilang previously approved these changes Nov 21, 2023
@HindujaB HindujaB dismissed stale reviews from gabilang and warunalakshitha via 0974f3f November 22, 2023 08:03
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

Copy link
Contributor

@Nadeeshan96 Nadeeshan96 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 f59419a into ballerina-platform:master Nov 23, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Data Binding doesn't Work as Expected for Records with Escape Characters
4 participants