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

Fix name annotation lookup logic and handle union as member type of array value #25

Closed
wants to merge 6 commits into from

Conversation

prakanth97
Copy link
Contributor

@prakanth97 prakanth97 commented Jul 3, 2024

Purpose

Fixes: #6689

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@prakanth97 prakanth97 requested a review from hasithaa as a code owner July 3, 2024 10:15
Copy link
Contributor

@NipunaRanasinghe NipunaRanasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prakanth97 I don't see any test source changes along with the fix, so I assume this is something we've missed to cover in the module's test suite.

So wouldn't it be better to add a test case to cover the fixed scenario?

@prakanth97 prakanth97 changed the title Fix name annotation lookup logic Fix name annotation lookup logic and handle union as member type of array value Jul 3, 2024
@prakanth97 prakanth97 requested a review from hasithaa July 3, 2024 14:20
record.put(bKeyName, ValueCreator.createArrayValue(value.toArray(),
TypeCreator.createArrayType(Constants.JSON_ARRAY_TYPE)));
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need to handle element being a Intersection scenario as well.

@Namespace {prefix: "ex1", uri: "example1.com"}
type Ex1_Reply record {
@Namespace {prefix: "ex1", uri: "example1.com"}
string Address;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add a another test where this attribute being another record?

Copy link
Contributor

@hasithaa hasithaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we need to add more test covering Union and intersection.

for (int i = 0; i < arrayValue.getLength(); i++) {
Object element = arrayValue.get(i);
Type actualElementType = getTypeFromUnionType(elementType, element);
if (actualElementType.getTag() == TypeTags.RECORD_TYPE_TAG) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the expected type is TypeTags.MAP_TYPE_TAG, this behaviour should be same ryt?

Copy link

@LakshanWeerasinghe LakshanWeerasinghe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets address the suggestions in another PR.

@prakanth97
Copy link
Contributor Author

This PR is not valid since it handles specific union type case for toXml method. The module is not supporting union as expected type at the moment hence closing the PR.

@prakanth97 prakanth97 closed this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

union array as expected type generate invalid result for record to xml conversion with toXml() function
5 participants