-
Notifications
You must be signed in to change notification settings - Fork 356
Fix $filter in (collectionofdynamicprimitivevalues) #3190
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 $filter in (collectionofdynamicprimitivevalues) #3190
Conversation
Run pipeline |
e0c2da4
to
cdefde9
Compare
$filter in (collectionofdynamicprimitivevalues)
$filter in (collectionofdynamicprimitivevalues)
...tTests/Microsoft.OData.Core.Tests/ScenarioTests/UriParser/FilterAndOrderByFunctionalTests.cs
Show resolved
Hide resolved
|
||
string content = bracketLiteralText[1..^1].Trim(); | ||
|
||
if (string.IsNullOrWhiteSpace(content)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the answer to this https://github.com/OData/odata.net/pull/3190/files#r1978721142, is this scenario possible?
I think that the first thing we should check is string.IsNullOrWhiteSpace
at the beginning of this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is after removing the first and last brackets and trimming the spaces before and after content. I also don't think at this point we can have null
or empty whitespaces without the brackets. So the check for isNullOrWhiteSpace
will always return false.
...tTests/Microsoft.OData.Core.Tests/ScenarioTests/UriParser/FilterAndOrderByFunctionalTests.cs
Show resolved
Hide resolved
I'm not opposed to this PR, but the way handle collection literals seems like a hack and all these PRs we make to patch edge cases are band-aids that are not sustainable in the long term. We should not be hacking the collection string to massage it into a JSON array so that we can parse it and then do special checks for edge cases. I believe the ideal, sustainable solution would be to handle the collection property from the lexer stage. By the time we get to the parser, we have an array start token, and array end token, and we know all the elements in between, the elements would have been properly tokenized based on the tokenizer rules for these literals. |
Issues
*This pull request fixes #3098, fixes #2875 *
Description
This PR (#2711) introduced a fix to support
$filter=dynamicProperty in ('')
. However, the changes in this PR inadvertently broke the handling of$filter=dynamicProperty in (primitive collections)
, such as$filter=dynamicProperty in (1,2,3)
.To address this, I've added a private method,
IsCollectionContentEmptyOrSpaces
, which checks whether a collection ofEdm.Untyped
is either empty or contains only spaces before further processing. If the collection meets this condition, the logic for ensuring a string collection gets properly formatted gets called.Previously, this string formatting logic was executed without verifying whether the
Edm.Untyped
collection contained empty spaces or not. As a result, it was being applied even when the collection contained primitive types (e.g., numbers) that do not require string formatting, leading to exceptions being thrown.Checklist (Uncheck if it is not completed)
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.