wso2 / ballerina-vscode

To keep Ballerina VSCode plugin related issues, discussions, etc.
Apache License 2.0
42 stars 20 forks source link

[Data Mapper] Transformation functions with union return types are not supporting query expressions within function body #422

Open madushajg opened 1 year ago

madushajg commented 1 year ago

Description: $Subject

Steps to reproduce: Sample code:

type Person record {
    string id;
    string firstName;
    string lastName;
    int age;
    string country;
};

type Student record {
    string id;
    string fullName;
    string age;
    record {
        string title;
        int credits;
    }[] courses;
    int totalCredits;
    string visaType;
};

function transform(Person[] people) returns Student[]|error => from var item in people
    select {}

Affected Versions: Ballerina 2201.3.2 Plugin v3.3.9

madushajg commented 1 year ago

This is causing due to: https://github.com/ballerina-platform/ballerina-lang/issues/39642 Should be resolved after fixing the above. Also we should add support for union return type within function definition level query expressions too (https://github.com/wso2-enterprise/ballerina-plugin-vscode/blob/dev/workspaces/data-mapper/src/components/Diagram/visitors/NodeInitVisitor.ts#L178)