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

Add support for a tuple of classes or types in the QueryBuilder.append #1607

Merged
merged 4 commits into from
May 30, 2018

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented May 30, 2018

Fixes #1398

The current implementation of QueryBuilder.append only allows to add a single orm class through the cls or type argument, however, often one would want to add a tuple of classes, provided they share a common base class. This pull request implements this functionality

lekah added 4 commits May 29, 2018 18:03
…, lists or sets as classes. This works now only for keyword cls and for the django backend, but the path has been laid out for the rest. Added also a test, that currently fails for types being set to tuples, since this is the next thing to fix
…/lists/set. A bit of code-refactoring was done to make the code a bit easier to read and avoid code-cuplication. This also prompted removing one method from the interface of the QueryBuilder. This issue is probably resolved at this stage, but a few more tests and additional documentation would not hurt
@sphuber sphuber requested a review from lekah May 30, 2018 08:38
@codecov-io
Copy link

Codecov Report

Merging #1607 into develop will increase coverage by 0.05%.
The diff coverage is 92.45%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1607      +/-   ##
===========================================
+ Coverage    57.11%   57.17%   +0.05%     
===========================================
  Files          273      273              
  Lines        33795    33773      -22     
===========================================
+ Hits         19302    19309       +7     
+ Misses       14493    14464      -29
Impacted Files Coverage Δ
aiida/backends/general/querybuilder_interface.py 59.18% <ø> (+0.36%) ⬆️
.../djsite/querybuilder_django/querybuilder_django.py 82.81% <ø> (-2.18%) ⬇️
aiida/backends/sqlalchemy/querybuilder_sqla.py 72.24% <ø> (+1.23%) ⬆️
aiida/orm/querybuilder.py 74.16% <92.45%> (+2.83%) ⬆️
aiida/backends/djsite/db/models.py 75.97% <0%> (+0.88%) ⬆️
aiida/backends/djsite/globalsettings.py 86.84% <0%> (+5.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d380cc4...054e4c1. Read the comment docs.

@lekah lekah merged commit d5f5d21 into develop May 30, 2018
sphuber added a commit that referenced this pull request May 30, 2018
#1607)

The `append` method of the `QueryBuilder` now accepts a tuple, list or set of orm classes
for the `cls` and `type` keyword argument, with the one restriction that all classes share a
common base class. This allows the user to append a join for a set of classes with the same
projection and filtering rules
@sphuber sphuber deleted the fix_1398_tuple_qb_append branch May 30, 2018 08:56
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 this pull request may close these issues.

3 participants