Skip to content
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

propOr doesn't like null #144

Closed
dhershman1 opened this issue Mar 31, 2020 · 4 comments · Fixed by #147
Closed

propOr doesn't like null #144

dhershman1 opened this issue Mar 31, 2020 · 4 comments · Fixed by #147
Assignees
Labels
bug 👾 Something isn't working question ❓ Further information is requested

Comments

@dhershman1
Copy link
Owner

dhershman1 commented Mar 31, 2020

Describe the bug
propOr is falling over on null values, this feels like a deja vu bug?

To Reproduce
Steps to reproduce the behavior:

  1. import propOr
  2. Pass it null, example: propOr('', ['name'], null)

Expected behavior
I believe propOr should return the default value on a null just like it would for undefined

@dhershman1 dhershman1 added bug 👾 Something isn't working question ❓ Further information is requested labels Mar 31, 2020
@dhershman1 dhershman1 self-assigned this Mar 31, 2020
@Glen-Cocoa
Copy link
Contributor

I'm having trouble reproducing, when i pass in null object propOr throws an error because it's trying to read a property off an object that doesn't exist. Seems to function as I would expect when the value stored at the accessed property is both null and undefined.

@Glen-Cocoa
Copy link
Contributor

So are you suggesting that when the accessed object doesnt exist, propOr should still return the default value?

@dhershman1
Copy link
Owner Author

correct, in my opinion it should behave the same as pathOr which reads the object and if that object does not exist (undefined or null) it returns the defaulted value.

@Glen-Cocoa
Copy link
Contributor

made a PR to fix behavior here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 👾 Something isn't working question ❓ Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants