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

Fixes #1126: enable built-in expression in $orderby #1150

Merged
merged 5 commits into from
Jan 11, 2024
Merged

Fixes #1126: enable built-in expression in $orderby #1150

merged 5 commits into from
Jan 11, 2024

Conversation

xuzhg
Copy link
Member

@xuzhg xuzhg commented Jan 3, 2024

Fixes #1126

Support odata query expression in $orderby. For example:

$orderby=tolower(name)
$orderby=year(Birthday)
....

/// <summary>
/// Represents the order by expression in the $orderby clause.
/// Use this to represent other $orderby except 'Property,OpenProperty,$count, $it' orderBy expression.
/// Again, in the next major release, we don't need this class.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest creating an issue to track this and tag it as a major release opportunity and then referencing the issue url here.

Copy link
Contributor

@habbes habbes Jan 8, 2024

Choose a reason for hiding this comment

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

Also, I think it's more suitable to put this in a <remarks> tag instead of the <summary>. #resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

#resolved

@@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.OData.Query
{
/// <summary>
/// Represents a single order by expression in the $orderby clause.
/// saxu: Why do we need this class and its derived type? only fetch the PropertyPath? In the next major release, we can consider to remove all of these.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest creating an issue to track and then referencing the issue url here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this note should go in the <remarks> instead of <summary>

Copy link
Member Author

Choose a reason for hiding this comment

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

#resolved

case ClrCanonicalFunctions.IndexofFunctionName:
result = AllowedFunctions.IndexOf;
break;
case "isof":
Copy link
Contributor

Choose a reason for hiding this comment

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

Why isn't this in ClrCanonicalFunctions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know why. But, I prefer to use "isof" directly in the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

#resolved.

/// </summary>
/// <param name="propertyAccessNode">The single value property access node.</param>
/// <param name="validatorContext">The validation context.</param>
protected virtual void ValidateSingleValuePropertyAccessNode(SingleValuePropertyAccessNode propertyAccessNode, OrderByValidatorContext validatorContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you add any tests on validation errors?

Copy link
Member Author

Choose a reason for hiding this comment

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

We already have the orderby validator tests in the UT: OrderByQueryValidatorTest.cs

habbes
habbes previously approved these changes Jan 11, 2024
@gathogojr
Copy link
Contributor

Curious there'd be any value in adding E2E tests to verify the behaviour against EF query provider.

gathogojr
gathogojr previously approved these changes Jan 11, 2024
Copy link
Contributor

@gathogojr gathogojr left a comment

Choose a reason for hiding this comment

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

Left a few comments, otherwise LGTM

@xuzhg xuzhg dismissed stale reviews from gathogojr and habbes via 08fe73a January 11, 2024 19:11
xuzhg and others added 2 commits January 11, 2024 11:11
…idator.cs

Co-authored-by: John Gathogo <john.gathogo@microsoft.com>
Co-authored-by: John Gathogo <john.gathogo@microsoft.com>
@xuzhg xuzhg merged commit e02297c into main Jan 11, 2024
1 of 2 checks passed
@xuzhg xuzhg deleted the issue1126 branch January 11, 2024 19:20
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.

Support tolower() in $orderby option
3 participants