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

Call clause #40

Merged
merged 9 commits into from
May 2, 2022
Merged

Call clause #40

merged 9 commits into from
May 2, 2022

Conversation

transistive
Copy link
Collaborator

I added support for the CALL clause for sub queries.

It's just a Clause accepting another query to build the subject with.

I also added a method on the Query object which uses a callable accepting a fresh query so the user can create something like this:

$node = Query::node('X')->named('y');
$query = Query::new()->match($node)
        ->call(function (Query $subQuery) use ($node) {
            $subQuery->with($node->getVariable())
                ->where($node->property('z')->equals(Query::literal('foo'), false))
                ->returning($node->property('z')->alias('foo'));
        })
        ->returning(Query::variable('foo'));

$this->assertEquals("MATCH (y:X) CALL { WITH y WHERE y.z = 'foo' RETURN y.z AS foo } RETURN foo", $query->toQuery());

@marijnvanwezel marijnvanwezel self-requested a review April 25, 2022 08:22
@transistive
Copy link
Collaborator Author

Partly solves issue #28

@marijnvanwezel
Copy link
Collaborator

I like the decorator approach, but I would also like the Query::call function to be able to accept a class of type Query directly.

src/Query.php Outdated Show resolved Hide resolved
src/Query.php Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@transistive
Copy link
Collaborator Author

transistive commented Apr 25, 2022 via email

@wgevaert
Copy link
Collaborator

I'm okay with adding it to the github ci, I don't know how to do that haha.

Concerning this pull request, note that CYPHER also allows for CALL procedures of the form CALL some.procedure() YIELD somestuff WHERE something RETURN stuff. Do you have any suggestions for how to go about implementing that in the future, when this will be implemented as suggested in this pull request?

(ofc we do not have to think about that right now, but we could).

Copy link
Collaborator

@wgevaert wgevaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Copy link
Collaborator

@marijnvanwezel marijnvanwezel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@wgevaert wgevaert merged commit 19837f8 into neo4j-php:main May 2, 2022
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