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

get(queryset[0].field) on empty queryset fails on upgrade to pydash 6.0.0 #179

Closed
AndyKilpatrick opened this issue Feb 20, 2023 · 1 comment

Comments

@AndyKilpatrick
Copy link

Upgrade Django code to use pydash 6.0.0, I hit the following behaviour change. Not 100% sure if this was an intended change.

Code runs value = pydash.get(qs, "[0].field"), where qs is a Django queryset which may or may not be empty:

For pydash >=6.0.0 this fails with a call stack like this

.venv/lib/python3.9/site-packages/pydash/objects.py:528: in get my code.py: obj = base_get(obj, key, default=sentinel) .venv/lib/python3.9/site-packages/pydash/helpers.py:139: in base_get value = _base_get_object(obj, key, default=default) .venv/lib/python3.9/site-packages/pydash/helpers.py:181: in _base_get_object _raise_if_restricted_key(key)

I think (apologies if this is wrong) this may be a problem accessing "[0]" which was previously handled, returning None.

@AndyKilpatrick AndyKilpatrick changed the title get(queryset[0].field) fails from 6.0.0 get(queryset[0].field) fails on upgrade to pydash 6.0.0 Feb 20, 2023
@AndyKilpatrick AndyKilpatrick changed the title get(queryset[0].field) fails on upgrade to pydash 6.0.0 get(queryset[0].field) on empty queryset fails on upgrade to pydash 6.0.0 Feb 20, 2023
@dgilland
Copy link
Owner

Should be fixed in v6.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants