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 #3174: Enable $select=colProperty/$count query option parser #3175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xuzhg
Copy link
Member

@xuzhg xuzhg commented Feb 9, 2025

Fixes #3174: Enable $select=colProperty/$count query option parser

See details in #3174

See related OASIS tc issues at: Should ABNF support /$count in $Select · Issue #2046 · oasis-tcs/odata-specs

@@ -319,6 +323,15 @@ private SelectItem GenerateSelectItem(SelectTermToken tokenIn)
parsedPath.AddRange(selectedPath);
SelectExpandClause selectExpand = BindSelectExpand(null, tokenIn.SelectOption, parsedPath, this.ResourcePathNavigationSource, targetNavigationSource, elementTypeReference, generatedProperties);

if (isCount)
{
// Do we need to throw exception if orderBy and nested select expand are not null within /$count ?
Copy link
Member

@mikepizzo mikepizzo Feb 26, 2025

Choose a reason for hiding this comment

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

Yes; here, or somewhere, we should return an error if there is anything other than $filter/$search nested in a /$count(...). See https://github.com/oasis-tcs/odata-abnf/blob/e0b11964a13bf6ebe614b67933da8af0c155de4a/abnf/odata-abnf-construction-rules.txt#L313C2-L313C5

@@ -964,15 +979,39 @@ private static void VerifySelectedPath(SelectTermToken selectedToken)
throw new ODataException(Error.Format(SRResources.SelectExpandBinder_SystemTokenInSelect, current.Identifier));
}

// Be design, the "/$count" should be built using SystemToken, but now, ODL is using NonSystemToken.
// Shall we support "no-dollar sign"?
Copy link
Member

Choose a reason for hiding this comment

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

/$count requires the '$', but ($count=true) does not.

@@ -170,6 +165,8 @@ private PathSegmentToken ParseSegment(PathSegmentToken previousSegment, bool all
this.lexer.NextToken();
}

// By design, "/$count" or "/$ref" should return using SystemToken, but the existing implementation is using "NonSystemToken".
// So far, let's keep it unchanged.
Copy link
Member

Choose a reason for hiding this comment

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

should we fix this in ODL9?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question

Assert.Null(selectCountItem.Search);
}

// $select=colProperty/$count($search=...)
Copy link
Member

@WanjohiSammy WanjohiSammy Feb 27, 2025

Choose a reason for hiding this comment

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

Can we have a test with nested expand, count and search.

For example:

  • $expand=colProperty($count($search=...))


Assert.Null(selectCountItem.Filter);
Assert.NotNull(selectCountItem.Search);
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to add tests for scenarios where there is anything other than $filter/$search nested in a /$count(...)

  • $select=colProperty/$count($orderby=...)
  • $select=colProperty/$count($select=...)
  • ...

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 to query number of collection property using /$count
4 participants