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

QueryBuilder: allow with_incoming/with_outgoing = None #3852

Open
yakutovicha opened this issue Mar 17, 2020 · 3 comments
Open

QueryBuilder: allow with_incoming/with_outgoing = None #3852

yakutovicha opened this issue Mar 17, 2020 · 3 comments

Comments

@yakutovicha
Copy link
Contributor

I propose to simplify the search for the nodes that don't have parents/children. This could be achieved by allowing with_incoming/with_outgoing parameters be set to None. Currently, this is not possible.

The way I currently search for StructureData that does not have parent nodes:

qbuild = QueryBuilder()

qbuild2 = QueryBuilder().append(StructureData, project=["id"], tag='structures')
qbuild2.append(Node, with_outgoing='structures')
processed_nodes = [n[0] for n in qbuild2.all()]
if processed_nodes:
    filters['id'] = {"!in": processed_nodes}
qbuild.append(self.what_query_for, filters=filters)

Would be cool to replace all of this by simply:

qbuild = QueryBuilder().append(StructureData, with_incoming=None)
@giovannipizzi
Copy link
Member

It would be good to discuss how to extend the query builder also for similar but slightly similar queries.

E.g.: query for a node not have a given input link (e.g. not having a link with a given label, and/or type?)

@yakutovicha
Copy link
Contributor Author

mentioning @lekah, @ramirezfranciscof in case you have ideas.

@lekah
Copy link
Contributor

lekah commented Apr 8, 2020

There was some code that was meant for these cases in the QB... It was removed in #3518 since it hadn't been updated after some ORM changes. If that code gets re-used, that needs to be fixed and it should be documented a bit more. But the code was solving that specific issue and could be reused to solve your problem. On the other hand, your code does work, so it's more of a convenience thing...

I would not use, however, your proposed solution of setting with_incoming to None, that is against the logic of the QB IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants