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
The updated README states that when includes_missing is false only attributes that have any value will be returned, but the code currently checks if the value evaluates to false instead of nil. Here is a failing test case that should pass:
it'should not consider as a missing attribute a value that evaluates to false'dosubject.paramsdorequires:firstoptional:falseendsubject.post'/declared'doerror!('expected false',400)ifdeclared(params,include_missing: false)[:false] != false''endpost'/declared',MultiJson.dump(first: 'one',false: false),'CONTENT_TYPE'=>'application/json'expect(last_response.status).toeq(201)end
However, I would argue that even attributes with nil values should not be considered "missing", since nil can be a valid value in some cases.
If the idea is to consider nil values as missing, this line should be:
nextunlessoptions[:include_missing] || children || !params[parent].nil?
But if nil should be considered a valid value, then we should only check for the attributes presence:
nextunlessoptions[:include_missing] || children || params.key?(parent)
What do you think?
The text was updated successfully, but these errors were encountered:
I think #816 introduced an unexpected behavior in this line: 0fda558#diff-e9e8424a5238d48301e313d8fe285697R41
The updated README states that when
includes_missing
isfalse
only attributes that have any value will be returned, but the code currently checks if the value evaluates tofalse
instead ofnil
. Here is a failing test case that should pass:However, I would argue that even attributes with
nil
values should not be considered "missing", since nil can be a valid value in some cases.If the idea is to consider nil values as missing, this line should be:
But if nil should be considered a valid value, then we should only check for the attributes presence:
What do you think?
The text was updated successfully, but these errors were encountered: