-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
hasPath does not work if one attribute in the path is undefined #2771
Comments
This is definitely a bug. Are you interested in creating a PR? |
I'll give it a try. Greettings! |
Hi @sespinozj, are you still into this issue? If you don't, I'd like to try cheers |
@machad0 do please go ahead. :) |
Hi again, Well, actually this bug was fixed at #2738, it's just an outdated bundle. var hasPath = _curry2(function hasPath(_path, obj) {
...
while (idx < _path.length) {
if (_has(_path[idx], val)) {
val = val[_path[idx]];
idx += 1;
} else {
return false;
}
the method doesn't contains the updated |
yes, thanks for checking that out @machad0 We use Greetings! |
Damn, I'm so caught up in what I want to do soon that I've forgotten what we've done recently! |
Just got bit by this bug, I don't think the fix is in the latest version (or it has come back):
|
@gouegd - First one fails for me, but the second one seems to work? (returns true as expected) Edit: This is strange... It failed in the REPL for me, but I just pulled master, wrote a test that should fail, from what I can tell, and it's passing...
|
@mattgrande That means the fix for #1 is on master but not published, doesn't it ? |
That's what it seems like, yes. |
I've been away from Ramda for a few weeks, and am trying to get back. I will try to publish again soon, and this change should then be included. |
Seems like there is still an issue. If the sub value isn't an Object (Object or Array), it fails. I ended up with this exact error message:
Fixed it by simply checking if the value is indeed an object and can be checked against a sub property with // hasPath function
...
while (idx < _path.length) {
if (!isNil(val) && is(Object, val) && _has(_path[idx], val)) {
val = val[_path[idx]];
idx += 1;
} else {
return false;
}
}
... :) |
Created a pull request #2825 for this issue |
* hasPath return false for non-object checks Used to throw an Error for non-object children tests Added test for object checking if val is an object when testing a path Added tests testing false is returned for non-objects children tests Related to github issue #2771 * Linting the file * Removed change as added to tests
Is this going to be fixed? We are still getting this issue... |
the issue still exists |
@gulsicka: Can you demonstrate? It seems to be working correctly in my test. |
hasPath does not work if one attribute in the path is undefined
If one of the object attributes in the path is undefined, hasPath throws an error. it should return false.
The text was updated successfully, but these errors were encountered: