From 354096555992da2702bfa854b7b15f48cd5f5ad8 Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Mon, 4 Jun 2012 09:33:31 -0500 Subject: [PATCH] batch cypher now working --- lib/neography/config.rb | 2 -- lib/neography/rest.rb | 7 +++++-- spec/integration/rest_batch_spec.rb | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/neography/config.rb b/lib/neography/config.rb index 643a53f..c59c529 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -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 \ No newline at end of file diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 3fd05db..da7fb4b 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -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 diff --git a/spec/integration/rest_batch_spec.rb b/spec/integration/rest_batch_spec.rb index a31346d..b4d2bf4 100644 --- a/spec/integration/rest_batch_spec.rb +++ b/spec/integration/rest_batch_spec.rb @@ -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