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 AutoExpand Issues with Capitalized $Expand System Query Options #1292

Merged
merged 16 commits into from
Sep 6, 2024

Conversation

WanjohiSammy
Copy link
Contributor

@WanjohiSammy WanjohiSammy commented Aug 5, 2024

Issues

This pull request fixes #1284.

Description

When using AutoExpand, and specifying a system query option that's not lower case (such as $Expand) an exception is thrown. The exception indicates that Expand is being added twice.

"message": "The query specified in the URI is not valid. Query option '$expand/expand' was specified more than once, but it must be specified at most once.",

This change is to resolve issues with the AutoExpand when using capitalized $Expand system query options

For example, given the following entities where Friends prop and Trip class are AutoExpand

public class Person
{
    public int Id { get; set; }

    public string? Name { get; set; }

    public IList<WeekDay>? WorkingDays { get; set; }

    [AutoExpand]
    public virtual ICollection<Person> Friends { get; set; }

    public virtual ICollection<Trip> Trips { get; set; }
}

[AutoExpand]
public class Trip
{
    public int Id { get; set; }

    public string? Name { get; set; }
}

With this change, we should be able to use $Expand(capitalized of $expand) with the AutoExpand navigation properties:

/People?$Expand=Friends
/People?$Expand=Trips
/People?$Expand=Friends,Trips
/People?$EXPAND=Friends

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.

@habbes
Copy link
Contributor

habbes commented Aug 14, 2024

@WanjohiSammy does this issue only affect AutoExpand? Also do we have tests for query options without a $ prefix?

@WanjohiSammy
Copy link
Contributor Author

@WanjohiSammy does this issue only affect AutoExpand? Also do we have tests for query options without a $ prefix?

@habbes This addresses the issue of Select or Expand AutoExpand navigation property using capitalized Select or Expand with or without $ prefix. I have added tests for query options without a $ prefix

@WanjohiSammy WanjohiSammy merged commit a77ed76 into release-8.x Sep 6, 2024
2 checks passed
WanjohiSammy added a commit that referenced this pull request Sep 9, 2024
…1292)

* Fix AutoExpand Issues with Capitalized $Expand System Query Options (#1292)
WanjohiSammy added a commit that referenced this pull request Sep 9, 2024
…1292)

* Fix AutoExpand Issues with Capitalized $Expand System Query Options (#1292)
WanjohiSammy added a commit that referenced this pull request Oct 25, 2024
… System Query Options (#1309)

* Fix AutoExpand Issues with Capitalized $Expand System Query Options (#1292)
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.

AutoExpand not working correctly with $Expand uri query parameters
4 participants