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

[Bug]: Cannot Create Enum Values with Assigned Values in Native Code #38846

Closed
ThisaruGuruge opened this issue Nov 28, 2022 · 4 comments · Fixed by #39002
Closed

[Bug]: Cannot Create Enum Values with Assigned Values in Native Code #38846

ThisaruGuruge opened this issue Nov 28, 2022 · 4 comments · Fixed by #39002
Assignees
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Improvement
Milestone

Comments

@ThisaruGuruge
Copy link
Member

Description

We have this bug in GraphQL package, where we cannot pass the correct enum value into a resource method parameter, when there's a value assigned to an enum member.

In the native code, I tried to access the union type related to the enum, but it only contains the assigned values, not the member type names. Without this information, the GraphQL bug cannot be fixed. Therefore, I think we should consider this as a bug.

Steps to Reproduce

No response

Affected Version(s)

Ballerina SwanLake Update 2 (2201.2.0)

This also affects the other versions as well.

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

#37115

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ThisaruGuruge
Copy link
Member Author

@warunalakshitha Do we have any update on this? Can we have this before the next patch release?

@warunalakshitha
Copy link
Contributor

@ThisaruGuruge We will check and update soon.

@Nadeeshan96
Copy link
Contributor

The fix will be provided with update 4 release. What we will be providing is this. You can call getName() on io.ballerina.runtime.api.types.FiniteType to get the user defined enum member type name. For example if there is a enum like this,

enum Weekday {
    SUNDAY = "Sunday",
    MONDAY = "Monday"
}

we need to iterate through enum UnionType.getMemberTypes() and call getName() on each of the member types. It will give SUNDAY and MONDAY. I have written a similar test in the PR.

@Nadeeshan96 Nadeeshan96 moved this from In Progress to PR Sent in Ballerina Team Main Board Dec 13, 2022
@github-project-automation github-project-automation bot moved this from PR Sent to Done in Ballerina Team Main Board Jan 5, 2023
@github-actions
Copy link

github-actions bot commented Jan 5, 2023

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.

@Nadeeshan96 Nadeeshan96 added this to the 2201.4.0 milestone Jan 31, 2023
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 Type/Improvement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants