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

Query: Parsing collect() results sometimes fails #18

Open
johannessen opened this issue Apr 24, 2018 · 3 comments
Open

Query: Parsing collect() results sometimes fails #18

johannessen opened this issue Apr 24, 2018 · 3 comments
Assignees
Labels

Comments

@johannessen
Copy link
Collaborator

Hi Mark,

I discovered REST::Neo4p is unable to parse the result of certain Cypher queries that use expressions calling Neo4j functions like collect() in the RETURN clause. Minimized example:

# set up graph for testing
my $q1 = REST::Neo4p::Query->new(<<END);
CREATE (a:Test)-[:TEST{test:true}]->(:Test)
RETURN id(a)
END
$q1->execute();
my $id = $q1->fetch->[0];

# test collecting properties that are undefined
my $q2 = REST::Neo4p::Query->new(<<END);
MATCH (p:Test)-[r]-(o) WHERE id(p) = {id}
RETURN collect(r.void)
END
$q2->execute(id => $id);
print Dumper $q2->fetch->[0];  # expected: []
# dies: Can't use an undefined value as an ARRAY reference at REST/Neo4p/Query.pm line 428.

# test collecting properties that have boolean values
my $q3 = REST::Neo4p::Query->new(<<END);
MATCH (p:Test)-[r]-(o) WHERE id(p) = {id}
RETURN collect(r.test)
END
$q3->execute(id => $id);
print Dumper $q3->fetch->[0];  # expected: [true]
# dies: Not a HASH reference at REST/Neo4p/Query.pm line 358.

This issue is reproducible for REST::Neo4p 0.3020 with Neo4j versions 2.3.3, 3.0.0 and 3.3.5.

I worked around this issue by simplifying my queries, so I don’t need a fix at this time. But I still wanted to document it.

Furthermore I clearly remember having similar problems with the substring() function. Which is quite mystifying since producing a simple string is of course all it does, and I fail to see why e. g. substring('1999-12-31', 0, 4) would fail where '1999' succeeds. However, I now seem to be unable to reproduce this issue, so I suppose it’s not just possible, but in fact probable I simply made a mistake of some sort there.

Cheers,
Arne

@majensen
Copy link
Owner

@johannessen this is a great bug, and I'll fix it and add a test-- hopefully soon.
Mark

@majensen majensen self-assigned this Apr 26, 2018
@majensen majensen added the bug label Apr 26, 2018
@majensen
Copy link
Owner

Probably still need to fix this!

@johannessen
Copy link
Collaborator Author

Running the example code above with the default agent reveals the following:

  • collect(r.void) no longer dies, but still returns undef (it's supposed to return an empty array ref [])
  • collect(r.test) still dies with the same message Not a HASH reference

But given that this issue is indeed not reproducible with the Neo4j::Driver agent, an easy solution might be to eventually make Neo4j::Driver the default agent.

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

No branches or pull requests

2 participants