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

Adding a condition to cast QueryNode to SingleResourceCastNode for Unquoted Type Parameter #1313

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

WanjohiSammy
Copy link

Issues

This pull request fixes #1304.

Description

This modification adds a condition to cast QueryNode to SingleResourceCastNode.

Currently, the QueryNode is only converted to ConstantNode and supports the cast function only with quoted type parameters. For unquoted type parameters, the QueryNode will be of type SingleResourceCastNode, resulting in an error because SingleResourceCastNode cannot be cast to ConstantNode.

For example, given the following entities:

namespace NS;

public class Person
{
    public int Id { get; set; }
    public string FullName { get; set; }
    public MyAddress Location { get; set; }
}

public class Employee : Person
{
    public string EmployeeNumber { get; set; }
}

public class MyAddress
{
    public string Street { get; set; }
}

public class WorkAddress : MyAddress
{
    public string OfficeNumber { get; set; }
}

With this change, we should be able to support these casts with unquoted type parameters:

  • cast(NS.Employee): cast Person to Employee
  • cast(Location, NS.WorkAddress): cast Location property to NS.WorkAddress

The following are currently supported :

  • cast('NS.Employee'): Quoted Employee type
  • cast(Location, 'NS.WorkAddress'): Quoted WorkAddress type

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

@WanjohiSammy WanjohiSammy requested review from xuzhg, habbes, mikepizzo and gathogojr and removed request for mikepizzo September 13, 2024 15:32
@WanjohiSammy WanjohiSammy marked this pull request as draft September 13, 2024 15:33
@WanjohiSammy WanjohiSammy force-pushed the fix/1304-missing-cast-singleresourcenode branch from eeb83f5 to 3d27793 Compare September 13, 2024 16:01
@WanjohiSammy WanjohiSammy marked this pull request as ready for review September 13, 2024 16:03
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.

Missing Cast to SingleResourceCastNode in BindSingleResourceCastFunctionCall Method in QueryBinder
2 participants