-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure correct types for
QueryBuilder().dict()
with multiple projec…
…tions The returned results by the backend implementation of `QueryBuilder` are passed through `get_aiida_entity_res` to convert backend instances to front end class instances. It calls `aiida.orm.convert.get_orm_entity` which is a singledispatch to convert all known backend types to its corresponding front-end ORM analogue. The registered implementation for `Mapping` contained the bug. It used a simple comprehension and did not catch any `TypeError` that might be thrown from values that could not be converted. This would bubble up to `get_aiida_entity_res` which would then simply return the original value. If the mapping contains a mixture of backend entities and normal types, the entire converting would be undone. This was surfaced when calling `dict` on a query builder instance with `project=['*', 'id']`. The returned value for each match is a dictionary with one value an integer corresponding to the `id` and the other value a backend node instance. The integer would raise the `TypeError` in the `Mapping` converter and since it wasn't caught, the backend node was also not converted.
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters