Repository navigation
Enable Where clause to generate $filter query options for key predicates - #1762
Conversation
odero
left a comment
There was a problem hiding this comment.
Considering how long this issue has existed I'm wondering if it might be a breaking change for people who might rely on this behaviour?
45c2c33 to
f9d25d5
Compare
|
@KenitoInc Can you please rebase the PR and get someone to approve it from the Nairobi team? #Closed |
|
@KanishManuja-MS I need to redesign a small feature so as not to break exisiting functionality. In the meantime I have removed this PR from v7.7 milestone #Closed |
f9d25d5 to
bb159a3
Compare
edfb389 to
5b52a5b
Compare
gathogojr
left a comment
There was a problem hiding this comment.
LGTM. I'd argue that in the next major version we shouldn't make this optional. We should just make it generate the $filter expression
96898ac to
e137d26
Compare
6c84b2f to
dac85cd
Compare
e45873b to
d943421
Compare
trying to understand how UseFilterAsPredicate relates to the new keyComparisonGeneratesFilterQuery. Do they do the same thing, but are set in different places? In what cases/why do we set UseFilterAsPredicate today? Would we have the same logic if line 278 was !input.UseFilterAsPredicate && !keyComparisonGeneratesFilterQuery, and removed the additional checks below? #Resolved Refers to: src/Microsoft.OData.Client/ALinq/ResourceBinder.cs:278 in 8368f37. [](commit_id = 8368f37, deletion_comment = False) |
|
@kennedy - See a couple comments. If we can get those resolved I'd love to merge. Also, please mark other comments as resolved as appropriate (i.e., in codeflow) to make it easier to track status of comments. Thanks! #Resolved |
@mikepizzo We can clean up the logic so as to work well with both. #Resolved |
|
Considering how long this issue has existed I'm wondering if it might be a breaking change for people who might rely on this behaviour? In reply to: 406936949 [](ancestors = 406936949) |
Issues
This pull request fixes issue #851 .
Description
The
Whereclause generates a Uri with a $filter where we have a non-key predicate e.gvar books = dsc.Books.Where(b => b.Title == "B1");creates the Uri belowhttps://serviceRoot/Books?$filter=Title eq 'B1'In this case, if the
Titleis not found, the query will return an empty collection.When we have a key in the predicate, the
Whereclause generates a Uri with a ByKey resource path e.gvar books = dsc.Books.Where(b => b.Id == 1);creates the Uri belowhttps://serviceRoot/Books(1)In this case, if the
Idis not found, the query will throw an exception.By design
Whereshould not throw an exception whenever the predicate does not match any value/element in the source collection.Solution
Changing the current behavior will be a breaking change. So I have added a
DataServiceContext.KeyComparisonGeneratesFilterQueryproperty which isfalseby default.So if a customer want to ensure that a Uri with a $filter query option is generated for key predicates in the
Whereclause, they need to set theKeyComparisonGeneratesFilterQueryproperty astrueChecklist (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.