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

options for handling non-persisted node upon assignment of an association #686

Closed

Conversation

dpisarewski
Copy link
Member

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 98.47% when pulling 41b2580 on dpisarewski:options_for_non_persisted_node into c1f6c76 on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 98.49% when pulling 41b2580 on dpisarewski:options_for_non_persisted_node into c1f6c76 on neo4jrb:master.

@subvertallchris
Copy link
Contributor

Sorry for sleeping on this. @cheerfulstoic this all good with you? I'd like to get that coverage back up over 98.5 so we can keep our 99%. :-D

@cheerfulstoic
Copy link
Contributor

I have a few comments (also sorry for sleeping on it):

  • I'd honestly like to see this as the default option, with the ability to turn it off if desired.
  • What's the hook for? I can see it's being passed self, so that's the node with the association. If it's not for something that you need, I would drop it. Otherwise I'd want better documentation and specs
  • Maybe the spec should check that an association is created too? I'm iffy on this one

@cheerfulstoic
Copy link
Contributor

Gah, I never know how to read coveralls. It says that coverage on some files went up and some went down, but only has_n.rb is changed here and that's not even in the list...

@dpisarewski
Copy link
Member Author

@cheerfulstoic you are right. The hook is kinda overengineering on this place. But I'm not sure if saving a node upon assignment should be turned off by default. I would not expect this on the user's place, though I also would not expect it to fail.

@dpisarewski
Copy link
Member Author

When I run specs, I get 7 failures with weird cypher queries like in #700, but there is no order clause.

Failures:

  1) query_proxy_methods match_to and first_rel_to match_to with a valid node generates a match to the given node
     Failure/Error: expect(@john.lessons.match_to(@history).to_cypher).to include('AND (ID(result_lessons) =')
       expected "MATCH (includestudent946:`IncludeStudent`), includestudent946-[rel0:`lessons`]->(result_lessons:`IncludeLesson`) WHERE ID(includestudent946) = {ID_includestudent946} AND ID(result_lessons) = {ID_result_lessons}" to include "AND (ID(result_lessons) ="
     # ./spec/e2e/query_proxy_methods_spec.rb:248:in `block (5 levels) in <top (required)>'

  2) query_proxy_methods match_to and first_rel_to match_to with an id generates cypher using the primary key
     Failure/Error: expect(@john.lessons.match_to(@history.id).to_cypher).to include('AND (result_lessons.uuid =')
       expected "MATCH (includestudent946:`IncludeStudent`), includestudent946-[rel0:`lessons`]->(result_lessons:`IncludeLesson`) WHERE ID(includestudent946) = {ID_includestudent946} AND result_lessons.uuid = {result_lessons_uuid}" to include "AND (result_lessons.uuid ="
     # ./spec/e2e/query_proxy_methods_spec.rb:258:in `block (5 levels) in <top (required)>'

  3) query_proxy_methods match_to and first_rel_to match_to with an array of nodes generates cypher using IN with the IDs of contained nodes
     Failure/Error: expect(@john.lessons.match_to([@history, @math]).to_cypher).to include('AND (result_lessons.uuid IN')
       expected "MATCH (includestudent946:`IncludeStudent`), includestudent946-[rel0:`lessons`]->(result_lessons:`IncludeLesson`) WHERE ID(includestudent946) = {ID_includestudent946} AND result_lessons.uuid IN {result_lessons_uuid}" to include "AND (result_lessons.uuid IN"
     # ./spec/e2e/query_proxy_methods_spec.rb:271:in `block (6 levels) in <top (required)>'

  4) query_proxy_methods match_to and first_rel_to match_to with a null object generates cypher with 1 = 2
     Failure/Error: expect(@john.lessons.match_to(nil).to_cypher).to include('AND (1 = 2')
       expected "MATCH (includestudent946:`IncludeStudent`), includestudent946-[rel0:`lessons`]->(result_lessons:`IncludeLesson`) WHERE ID(includestudent946) = {ID_includestudent946} AND 1 = 2" to include "AND (1 = 2"
     # ./spec/e2e/query_proxy_methods_spec.rb:288:in `block (5 levels) in <top (required)>'

  5) Neo4j::ActiveNode::Query.query_as can be built upon
     Failure/Error: @class_a.query_as(:q).match('q--p').where(p: {name: 'Brian'}).to_cypher.should == 'MATCH (q:`Person`), q--p WHERE (p.name = {p_name})'
       expected: "MATCH (q:`Person`), q--p WHERE (p.name = {p_name})"
            got: "MATCH (q:`Person`), q--p WHERE p.name = {p_name}" (using ==)
     # ./spec/unit/query_spec.rb:37:in `block (3 levels) in <top (required)>'

  6) Neo4j::ActiveNode::Query#query_as generates a basic query
     Failure/Error: @class_a.new.query_as(:q).to_cypher.should == 'MATCH (q:`Person`) WHERE (ID(q) = {ID_q})'
       expected: "MATCH (q:`Person`) WHERE (ID(q) = {ID_q})"
            got: "MATCH (q:`Person`) WHERE ID(q) = {ID_q}" (using ==)
     # ./spec/unit/query_spec.rb:43:in `block (3 levels) in <top (required)>'

  7) Neo4j::ActiveNode::Query#query_as can be built upon
     Failure/Error: @class_a.new.query_as(:q).match('q--p').return(p: :name).to_cypher.should == 'MATCH (q:`Person`), q--p WHERE (ID(q) = {ID_q}) RETURN p.name'
       expected: "MATCH (q:`Person`), q--p WHERE (ID(q) = {ID_q}) RETURN p.name"
            got: "MATCH (q:`Person`), q--p WHERE ID(q) = {ID_q} RETURN p.name" (using ==)
     # ./spec/unit/query_spec.rb:47:in `block (3 levels) in <top (required)>'

Finished in 31.86 seconds
696 examples, 7 failures, 4 pending

@subvertallchris
Copy link
Contributor

Update your neo4j-core, I think that'll fix those failures.

On Tuesday, March 10, 2015, Dieter Pisarewski notifications@github.com
wrote:

When I run specs, I get 7 failures with weird cypher queries like in #700
#700, but there is no order
clause.

Failures:

  1. query_proxy_methods match_to and first_rel_to match_to with a valid node generates a match to the given node
    Failure/Error: expect(@john.lessons.match_to(@history).to_cypher).to include('AND (ID(result_lessons) =')
    expected "MATCH (includestudent946:IncludeStudent), includestudent946-[rel0:lessons]->(result_lessons:IncludeLesson) WHERE ID(includestudent946) = {ID_includestudent946} AND ID(result_lessons) = {ID_result_lessons}" to include "AND (ID(result_lessons) ="

    ./spec/e2e/query_proxy_methods_spec.rb:248:in `block (5 levels) in <top (required)>'

  2. query_proxy_methods match_to and first_rel_to match_to with an id generates cypher using the primary key
    Failure/Error: expect(@john.lessons.match_to(@history.id).to_cypher).to include('AND (result_lessons.uuid =')
    expected "MATCH (includestudent946:IncludeStudent), includestudent946-[rel0:lessons]->(result_lessons:IncludeLesson) WHERE ID(includestudent946) = {ID_includestudent946} AND result_lessons.uuid = {result_lessons_uuid}" to include "AND (result_lessons.uuid ="

    ./spec/e2e/query_proxy_methods_spec.rb:258:in `block (5 levels) in <top (required)>'

  3. query_proxy_methods match_to and first_rel_to match_to with an array of nodes generates cypher using IN with the IDs of contained nodes
    Failure/Error: expect(@john.lessons.match_to([@history, @math]).to_cypher).to include('AND (result_lessons.uuid IN')
    expected "MATCH (includestudent946:IncludeStudent), includestudent946-[rel0:lessons]->(result_lessons:IncludeLesson) WHERE ID(includestudent946) = {ID_includestudent946} AND result_lessons.uuid IN {result_lessons_uuid}" to include "AND (result_lessons.uuid IN"

    ./spec/e2e/query_proxy_methods_spec.rb:271:in `block (6 levels) in <top (required)>'

  4. query_proxy_methods match_to and first_rel_to match_to with a null object generates cypher with 1 = 2
    Failure/Error: expect(@john.lessons.match_to(nil).to_cypher).to include('AND (1 = 2')
    expected "MATCH (includestudent946:IncludeStudent), includestudent946-[rel0:lessons]->(result_lessons:IncludeLesson) WHERE ID(includestudent946) = {ID_includestudent946} AND 1 = 2" to include "AND (1 = 2"

    ./spec/e2e/query_proxy_methods_spec.rb:288:in `block (5 levels) in <top (required)>'

  5. Neo4j::ActiveNode::Query.query_as can be built upon
    Failure/Error: @class_a.query_as(:q).match('q--p').where(p: {name: 'Brian'}).to_cypher.should == 'MATCH (q:Person), q--p WHERE (p.name = {p_name})'
    expected: "MATCH (q:Person), q--p WHERE (p.name = {p_name})"
    got: "MATCH (q:Person), q--p WHERE p.name = {p_name}" (using ==)

    ./spec/unit/query_spec.rb:37:in `block (3 levels) in <top (required)>'

  6. Neo4j::ActiveNode::Query#query_as generates a basic query
    Failure/Error: @class_a.new.query_as(:q).to_cypher.should == 'MATCH (q:Person) WHERE (ID(q) = {ID_q})'
    expected: "MATCH (q:Person) WHERE (ID(q) = {ID_q})"
    got: "MATCH (q:Person) WHERE ID(q) = {ID_q}" (using ==)

    ./spec/unit/query_spec.rb:43:in `block (3 levels) in <top (required)>'

  7. Neo4j::ActiveNode::Query#query_as can be built upon
    Failure/Error: @class_a.new.query_as(:q).match('q--p').return(p: :name).to_cypher.should == 'MATCH (q:Person), q--p WHERE (ID(q) = {ID_q}) RETURN p.name'
    expected: "MATCH (q:Person), q--p WHERE (ID(q) = {ID_q}) RETURN p.name"
    got: "MATCH (q:Person), q--p WHERE ID(q) = {ID_q} RETURN p.name" (using ==)

    ./spec/unit/query_spec.rb:47:in `block (3 levels) in <top (required)>'

Finished in 31.86 seconds
696 examples, 7 failures, 4 pending


Reply to this email directly or view it on GitHub
#686 (comment).

@dpisarewski
Copy link
Member Author

Thanks Chris, that solved the problem.

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.

None yet

4 participants