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

Exception for deep list filter #4

Open
Kudo opened this issue Dec 9, 2015 · 0 comments
Open

Exception for deep list filter #4

Kudo opened this issue Dec 9, 2015 · 0 comments
Assignees

Comments

@Kudo
Copy link
Owner

Kudo commented Dec 9, 2015

Given

collection_filter({'aList': [{'anotherList': [{'foo': 1, 'bar': 2}]}]}, 'aList[].anotherList[].foo')

Will throw exception:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-11-0e52659d65b7> in <module>()
----> 1 collection_filter({'aList': [{'anotherList': [{'foo': 1, 'bar': 2}]}]}, 'aList[].anotherList[].foo')

/Users/kudo/.virtualenvs/biienv/lib/python2.7/site-packages/collection_filter-0.5-py2.7.egg/collection_filter/collection_filter.pyc in collection_filter(data, fields)
    111         # [2] For each dot notated sub field, do further query recursively
    112         next_field, remain_query = _get_next_field(field)
--> 113         subset = _inner_filter(copy.deepcopy(data), next_field, remain_query)
    114         if data_as_list:
    115             # [3-1] For list, set each element as merged dictionary

/Users/kudo/.virtualenvs/biienv/lib/python2.7/site-packages/collection_filter-0.5-py2.7.egg/collection_filter/collection_filter.pyc in _inner_filter(data, field, remain_query, expect_list)
     80                                    next_field,
     81                                    remain_query,
---> 82                                    expect_list=expect_list)
     83
     84         # Return {field: result} if there are existed next query

/Users/kudo/.virtualenvs/biienv/lib/python2.7/site-packages/collection_filter-0.5-py2.7.egg/collection_filter/collection_filter.pyc in _inner_filter(data, field, remain_query, expect_list)
     51                                       field,
     52                                       remain_query,
---> 53                                       expect_list=False)
     54         return data
     55     else:

/Users/kudo/.virtualenvs/biienv/lib/python2.7/site-packages/collection_filter-0.5-py2.7.egg/collection_filter/collection_filter.pyc in _inner_filter(data, field, remain_query, expect_list)
     80                                    next_field,
     81                                    remain_query,
---> 82                                    expect_list=expect_list)
     83
     84         # Return {field: result} if there are existed next query

/Users/kudo/.virtualenvs/biienv/lib/python2.7/site-packages/collection_filter-0.5-py2.7.egg/collection_filter/collection_filter.pyc in _inner_filter(data, field, remain_query, expect_list)
     55     else:
     56         # `data` is dict
---> 57         assert type(data) == dict
     58         if not field:
     59             # If current field query is empty, try to fetch next query

AssertionError:
@Kudo Kudo self-assigned this Dec 9, 2015
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

1 participant