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

[Improvement]: Ability to call a function with parameters from the LHS and assign the return value to a RHS field #40236

Open
chathurace opened this issue Apr 17, 2023 · 1 comment
Assignees
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Editor

Comments

@chathurace
Copy link
Contributor

Description

Let's say that we have get a message m1 of the below type:

type Person record {|
   string name;
   string country;
   record {| string street; string city; |} address;
|};

Now we want to transform this to an instance m2 of the below type:

type Employee {|
   string name;
   string address;
   string countryCode;
|}

So the transformation would be:

function transform(Person person) returns Employee => {
    name: person.name,
    countryCode: lookupCountryCode(person.country),
    address: constructAddress(person.address.street, person.address.city)
};

However, it is not possible to create this transformation using the data mapper as function calls with parameters from left hand side fields are not supported.

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Editor

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Editor labels Apr 17, 2023
@madushajg madushajg self-assigned this Apr 18, 2023
@madushajg
Copy link
Contributor

I was able to achieve the above requirement in plugin v4.1.0 and Ballerina 2201.5.0 as below.
fn-call-with-params
@chathurace hope this addresses your requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Type/Improvement userCategory/Editor
Projects
Status: On Hold
Development

No branches or pull requests

3 participants