Skip to content

Commit

Permalink
batch cypher now working
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jun 4, 2012
1 parent ac746b1 commit 3540965
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions lib/neography/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class << self; attr_accessor :protocol, :server, :port, :directory, :cypher_path
@authentication = {}
@username = nil
@password = nil
#@parser = {:parser => YajlParser}
#@parser = {:parser => CrackParser}
@parser = {:parser => OjParser}
end
end
7 changes: 5 additions & 2 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,12 @@ def get_batch(args)
{:method => "GET", :to => "/node/#{get_id(args[1])}/relationships/#{args[2] || 'all'}"}
when :execute_script
{:method => "POST", :to => @gremlin_path, :body => {:script => args[1], :params => args[2]}}
# execute_query returning "exception => java.lang.NullPointerException"
when :execute_query
{:method => "POST", :to => @cypher_path, :body => {:query => args[1], :params => args[2]}}
if args[2]
{:method => "POST", :to => @cypher_path, :body => {:query => args[1], :params => args[2]}}
else
{:method => "POST", :to => @cypher_path, :body => {:query => args[1]}}
end
else
raise "Unknown option #{args[0]}"
end
Expand Down
7 changes: 4 additions & 3 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,18 @@
batch_result = @neo.batch [:execute_query, "start n=node(0) return n"]
batch_result.first.should have_key("id")
batch_result.first.should have_key("from")
pending "exception => java.lang.NullPointerException"
batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == "0"
end

it "can batch cypher with parameters" do
new_node = @neo.create_node
id = new_node["self"].split('/').last
batch_result = @neo.batch [:execute_script, "start n=node({id}) return n", {:id => id.to_i}]
batch_result = @neo.batch [:execute_query, "start n=node({id}) return n", {:id => id.to_i}]
batch_result.first.should have_key("id")
batch_result.first.should have_key("from")
pending "exception => java.lang.NullPointerException"
batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == id
end


end

Expand Down

0 comments on commit 3540965

Please sign in to comment.