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

Unable to map enum types when retrieving data with SQL connectors #4588

Closed
kaneeldias opened this issue Jun 20, 2023 · 1 comment · Fixed by ballerina-platform/module-ballerina-sql#663
Assignees
Labels
Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Milestone

Comments

@kaneeldias
Copy link
Contributor

kaneeldias commented Jun 20, 2023

Description:
If we attempt to retrieve a record from a database and map it a record type consisting of an enum type, we'd get an error similar to the following.
The field 'gender' of type Gender cannot be mapped to the column 'gender' of SQL type 'varchar'

Steps to reproduce:

public enum Gender {
    MALE,
    FEMALE
}

public type Employee record {|
    readonly string empNo;
    string firstName;
    string lastName;
    time:Date birthDate;
    Gender gender;
    time:Date hireDate;
|};
CREATE TABLE Employee (
    empNo VARCHAR(36) PRIMARY KEY,
    firstName VARCHAR(30),
    lastName VARCHAR(30),
    birthDate DATE,
    gender ENUM('MALE', 'FEMALE') NOT NULL,
    hireDate DATE,
);
stream<Employee, sql:Error?> employeeStream = dbClient->query(`SELECT * FROM Employee`);
Employee[] employees = check from Employee employee in employeeStream
    select employee;
@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant