fix(AIP-160): clarify unset field in traversal behavior#1469
fix(AIP-160): clarify unset field in traversal behavior#1469noahdietz merged 8 commits intoaip-dev:masterfrom
Conversation
| **may** permit traversal to undefined keys on maps and structs, and **should** | ||
| document how it behaves in this situation. | ||
|
|
||
| When evaluating an expression involving a traversal, if any non-primitive field |
There was a problem hiding this comment.
What about if the comparison is a "not equal" one?
There was a problem hiding this comment.
Regardless of the comparison in that case, it is skipped, at least that is my understanding of the feedback I got from maintainers. Unset == no value comparison at all.
I believe this is because of the ambiguity of the intent in such a filter - do they want to filter for entries that have a set and a.b != "foo" OR do they want to filter for entries that either do not have a set or a set and a.b != "foo".
This is where a Has operator would come into play e.g. "has: a AND a.b != "foo""
There was a problem hiding this comment.
That makes sense - but maybe it would be good to include an inequality in the list (or highlight it here) to make it clear? Basically, if I wasn't sure of the behavior without clarification, I suspect others may be in a similar position.
There was a problem hiding this comment.
Right, fair enough! I've included a sentence to this effect - same logic applies even when using != which would imply matching on empty values.
Clarify the expected behavior when a non-primitive field in a traversal operator's chain of fields is not set, it should be skipped i.e. not matched. This has been the expected behavior since inception, but was undocumented.
Internal bug http://b/388065878