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

forbidden to pass list of classes to QueryBuilder #2418

Closed
ltalirz opened this issue Jan 23, 2019 · 3 comments
Closed

forbidden to pass list of classes to QueryBuilder #2418

ltalirz opened this issue Jan 23, 2019 · 3 comments
Assignees

Comments

@ltalirz
Copy link
Member

ltalirz commented Jan 23, 2019

On provenance_redesign, I cannot pass a list of classes to the QueryBuilder:

In [1]: qb=QueryBuilder()

In [2]: qb.append([Node,Node])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-e54667174ba5> in <module>()
----> 1 qb.append([Node,Node])

/Users/leopold/Personal/Postdoc-MARVEL/repos/aiida/aiida_rmq/aiida/orm/querybuilder.py in append(self, cls, type, tag, filters, project, subclassing, edge_tag, edge_filters, edge_project, outerjoin, **kwargs)
    568
    569             else:
--> 570                 self._cls_to_tag_map[cls] = tag
    571                 l_class_added_to_map = True
    572

TypeError: unhashable type: 'list'

Using a tuple instead seems to work fine

In [1]: qb=QueryBuilder()

In [2]: qb.append((Node,Node))
Out[2]: <aiida.orm.querybuilder.QueryBuilder at 0x112105350>

Should lists be allowed?
If yes, this should be fixed and tested.
If not, we should change the documentation of QueryBuilder.append

@lekah
Copy link
Contributor

lekah commented Jan 23, 2019

I would say that's linked to #1398
@sphuber would know the design choices taken.

@ltalirz
Copy link
Member Author

ltalirz commented Jan 28, 2019

@sphuber agrees that it should be possible to pass a list

ltalirz added a commit to ltalirz/aiida-core that referenced this issue Jan 30, 2019
fix aiidateam#2418

 * convert lists/sets to tuples for cls <> tag list
 * add test that uses list instead of tuple
@sphuber
Copy link
Contributor

sphuber commented Mar 1, 2019

Fixed in PR #2421

@sphuber sphuber closed this as completed Mar 1, 2019
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

3 participants