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

The CSV file read as a record failed when a nillable field was empty #7433

Closed
daneshk opened this issue Dec 3, 2024 · 1 comment · Fixed by ballerina-platform/module-ballerina-io#1313
Assignees
Labels
module/io Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug

Comments

@daneshk
Copy link
Member

daneshk commented Dec 3, 2024

Description

If a record has a nullable field and we don't provide a value for that field in the CSV content, the application fails with an error.

Record type and CSV file does not match.

Expected:
Should not fail and assign () value for that field

Steps to Reproduce

Run the below sample

Sample code:

public function main() returns error? {
    stream<Person, io:Error?> streamValue = check io:fileReadCsvAsStream("test1.csv");
    check from Person p in streamValue
    do {
        io:println(p);
    };
}

type Person record {|
    int id;
    string? name;
    int age;
|};

Sample CSV file

"id","name","age"
1,"Alice",20
2,,12

Version

1.6.1

Environment Details (with versions)

No response

@daneshk daneshk self-assigned this Dec 3, 2024
@daneshk daneshk changed the title CSV file read as record failed when nillable field doesn't have a value in the CSV The CSV file read as a record failed when a nillable field was empty Dec 3, 2024
Copy link

github-actions bot commented Dec 4, 2024

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@daneshk daneshk added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/io Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant