0

It's issue similar to this question , but in my case 'neo4j-core' gem version is updated from 7.0.4 to 8.1.0, and 'neo4j' 8.0.7 -> 8.3.4

class Person
  include Neo4j::ActiveNode
  has_one :out, :ancestor, rel_class: :HasFather
end

class HasFather
  include Neo4j::ActiveRel
  from_class :Person
  to_class :Person
  type 'HAS_FATHER'
end

There is 'show' method where I have code

@ancestors = @person.ancestor(rel_length: 1..4)

Before update it worked perfectly and method returned an array with 4 persons. But now it return only one person.

Person#ancestor 
  MATCH (previous:`Person`)
  WHERE (ID(previous) = {ID_previous})
  OPTIONAL MATCH (previous)-[rel1:`HAS_FATHER`]->(next:`Person`)
  RETURN 
    ID(previous), 
    collect(next) | {:ID_previous=>38}
ETHON: performed EASY effective_url=http://localhost:7474/db/data/transaction/commit response_code=200 return_code=ok total_time=0.01983900000000005

@ancestors = #<AssociationProxy Person#ancestor [#<Person uuid: "f4454bcb-ffc8-4050-a486-0e7172ea864a", generation: nil, name...
balyam
  • 1
  • 2
  • Interesting, thanks for noting this! It would be helpful if you could pinpoint the version of the gem that cause it (it's almost certainly from the `neo4j` gem). – Brian Underwood Mar 07 '18 at 01:03
  • From my 'gem list' : neo4j (8.3.4, 8.0.11, 8.0.7, 7.2.3) neo4j-community (2.2.4.1) neo4j-core (8.1.0, 7.0.8, 7.0.4, 6.1.6) neo4j-rake_tasks (0.7.11, 0.7.10, 0.7.9) neo4j-rspec (0.2.4) – balyam Mar 07 '18 at 04:12
  • I am trying to use different options, like 'rel_length: 4', 'rel_length: {max: 4}' and it returns only Person on 'to_node' relation. – balyam Mar 07 '18 at 04:43
  • I think that `InverseFalcon`'s insight was right. If the variable length pattern isn't showing up in the Cypher query, changing the options isn't going to change anything. But I know that you're using `neo4j` 8.3.4. What I'm suggesting is that you try different versions (by changing your `Gemfile`) between version 8.0.7 and 8.3.4 to find out which version specifically introduced this change. I would think it would have been one of the minor versions (8.1.0, 8.2.0, or 8.3.0) – Brian Underwood Mar 08 '18 at 13:47
  • You can see all of the versions here: https://rubygems.org/gems/neo4j/versions – Brian Underwood Mar 08 '18 at 13:47
  • Thank you for your help, Brian! I was chahging gem versions in Gemfile and I have results: 8.0.7 or 8.1.0 or 8.1.5 works properly. Version 8.2.1 does not work properly. – balyam Mar 13 '18 at 08:25
  • I just tried your code and I'm getting the `*1..4` bit in the Cypher query. Do you see that difference in the Cypher query when changing versions? Because if it's there, I think you should get what you're expecting... – Brian Underwood Mar 20 '18 at 16:26

2 Answers2

0

That cypher query isn't showing a variable-length relationship. Assuming previous only has a single father, you're always collecting on a single node at most.

You may want to review the syntax for variable-length patterns:

OPTIONAL MATCH (previous)-[rel1:`HAS_FATHER`*..4]->(next:`Person`)
InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
0

I'm looking into this, but I'm curious what happens when you do this:

@ancestors = @person.ancestor(nil, nil, rel_length: 1..4)

I'm looking at the difference between 8.1.5 and 8.2.1 and it seems to be mostly around with_associations. I'm pretty sure rel_length is still working in general after 8.2.x, but if that line of code doesn't work then maybe I'm wrong about that....

Brian Underwood
  • 10,746
  • 1
  • 22
  • 34
  • within gem version 8.1.5 (nil, nil, rel_length: 1..4) works fine. If I changing version to 8.2.1 then works as I described in start topic. – balyam Mar 15 '18 at 17:15