Search code examples
neo4jkaminarineo4j.rb

Neo4j - pagination with kaminari - stack level too deep


I have many authors (as nodes) authoring multiple Work of Arts (wokas), also as nodes. I want to fetch the authors on page 100, 5 authors per page. For the first author from those five selected I want to know the first work of art authored. Here is my code and the error encountered. How this can be fixed?

irb(main):021:0* a = Author.page(100).per(5)
=> #<Kaminari::Neo4j::Paginated:0x007fde539b3c30 @source=Author(author_name: String), @current_page=100, @per_page=5>
irb(main):022:0> a.first
 CYPHER 792ms MATCH (result_author:`Author`) RETURN result_author SKIP {skip_495} LIMIT {limit_5} | {:skip_495=>495, :limit_5=>5}
=> #<Author uuid: nil, author_name: "1520?, Pittoni Battista, B.">

irb(main):023:0> w = a.first.wokas.first
 CYPHER 361ms MATCH (result_author:`Author`) RETURN result_author SKIP {skip_495} LIMIT {limit_5} | {:skip_495=>495, :limit_5=>5}
 Author#wokas 85038ms MATCH (previous:`Author`) OPTIONAL MATCH previous-[rel1:`AUTHORED_BY`]->(next:`Woka`) WHERE (ID(previous) IN {ID_previous}) RETURN ID(previous), collect(next) | {:ID_previous=>[19800172, 19800173, 19800174, 19800175, 19800176]}
SystemStackError: stack level too deep
    from /Users/levi/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/neo4j-5.0.11/lib/neo4j/active_node/has_n.rb:154:in `previous_proxy_results_by_previous_id'

Another statement failing with the same error.

irb(main):003:0> w = a.first.wokas.count
 CYPHER 372ms MATCH (result_author:`Author`) RETURN result_author SKIP {skip_495} LIMIT {limit_5} | {:skip_495=>495, :limit_5=>5}
 Author#wokas 99625ms MATCH (previous:`Author`) OPTIONAL MATCH previous-[rel1:`AUTHORED_BY`]->(next:`Woka`) WHERE (ID(previous) IN {ID_previous}) RETURN ID(previous), collect(next) | {:ID_previous=>[19800172, 19800173, 19800174, 19800175, 19800176]}
SystemStackError: stack level too deep

Solution

  • I realized I should provide this an an answer ;)

    I think that this was fixed in version 5.0.12 of the neo4j gem. Could you update and see if that works?