You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interesting edge condition. Not sure if the correct fix is to update the behavior or to updated the documentation. A root level document can only be in one of two states: an object or UNDEFINED. Undefined content is not a map, it's nothing. So the statement {..,"nofield":~} evaluates to false for UNDEFINED content just as it would if the content were any other non-object value (false, "a string", and so on), because the expected behavior when a conditional is for a non-matching data type is to return false.
Consider the following non-deleted content:
{
"x": "a string"
}
and the conditional:
{..,"x":{..,"nofield":~}}
In this case it's more clear that the conditional should evaluate to false since the data type for the actual value of "x" is incapable of matching the condition which requires an object value.
I agree that in your example, the semantics clearly indicate the condition will evaluate to false.
The difference is that when I do a get on your document, I'll clearly see that x is a string, and therefore will not match an object delta of any kind.
However, in my example, when you do a get on the document, it does come back as an object, so it's not clear at all that the object delta will not match.
This is an inconistency introduced by showing me an "empty" object but applying UNDEFINED during delta application. My recommendation would be to replace UNDEFINED with {} during delta application.
This may of course have some potential edge cases to consider, but it's valuable to present an internally consistent interface.
I guess it bears mention that {} is only valid as a replacement for UNDEFINED if the value in question is known to be an object, which is the case for Emo documents.
What is the Issue?
There is an apparent contradiction between Emo's never-null doc get api and conditional application.
How to Test and Verify
Start Emo and run through this scenario:
I start out by deleting the doc so we know it doesn't exist...
Risk
Level
Low
: I can just always use the redundant conditionalor(~, {..,"nofield":~})
. New users will find this behavior confusing, though... 'cause it is ;)Issue Checklist
Make sure to label the issue.
Well documented description of use-cases and bugs.
The text was updated successfully, but these errors were encountered: