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

Bad returned type for Collection.index_information #39

Open
Guibod opened this issue Mar 12, 2023 · 1 comment · May be fixed by #42
Open

Bad returned type for Collection.index_information #39

Guibod opened this issue Mar 12, 2023 · 1 comment · May be fixed by #42

Comments

@Guibod
Copy link
Contributor

Guibod commented Mar 12, 2023

Mongita Collection returns a List[Dict], and should instead return a MutableMapping[str, Any]
See https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.index_information

My suggested implementation:

def index_information(self):
    ret = {'_id_': {'key': [('_id', 1)]}}
    metadata = self._Collection__get_metadata()
    for idx in metadata.get('indexes', {}).values():
        ret[idx['_id']] = {'key': [(idx['key_str'], idx['direction'])]}
    return ret
@scottrogowski
Copy link
Owner

This looks correct as well. Not sure how I messed that up first round through. Still need a few days to get it in

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

Successfully merging a pull request may close this issue.

2 participants