Skip to content

Commit

Permalink
Skip label lookup for rel creation to fix core compat
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Feb 16, 2015
1 parent 9a019c1 commit 7a62856
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/neo4j/active_node/query/query_proxy.rb
Expand Up @@ -184,7 +184,7 @@ def _nodeify(*args)

def _create_relationship(start_object, other_node, properties)
_session.query(context: @options[:context])
.match(start: match_label(start_object), end: match_label(other_node))
.match(:start, :end)
.where(start: {neo_id: start_object.neo_id}, end: {neo_id: other_node.neo_id})
.send(create_method, "start#{_association_arrow(properties, true)}end").exec
end
Expand Down Expand Up @@ -360,7 +360,13 @@ def links_for_order_arg(arg)
end

def match_label(node)
node.class.mapped_label_name if node.class.respond_to?(:mapped_label_name)
if node.class.respond_to?(:mapped_label_name)
node.class.mapped_label_name
elsif node.respond_to?(:labels)
node.labels.first
else
''
end
end

def match_string(node)
Expand Down
3 changes: 2 additions & 1 deletion spec/e2e/neo4j-core_spec.rb
Expand Up @@ -12,7 +12,8 @@
obj = clazz.create
node = Neo4j::Node.create
obj.stuff << node
result = Neo4j::Session.query.match(:n).where("ID(n) = #{obj.neo_id}").match('(n)-[:stuff]->(m)').pluck(:m)
result = Neo4j::Session.query.match(:n).where("ID(n) = {obj_neo_id}").params(obj_neo_id: obj.neo_id).match('(n)-[:stuff]->(m)')
result = result.pluck(:m)
expect(result).to eq([node])
end

Expand Down

0 comments on commit 7a62856

Please sign in to comment.