Skip to content

Commit

Permalink
Merge pull request #92 from ceterumnet/master
Browse files Browse the repository at this point in the history
Possible issue with Batch query interface (this time with a failing test)
  • Loading branch information
maxdemarzi committed Apr 19, 2013
2 parents aa6c1ae + 0eee207 commit c6dad85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
14 changes: 13 additions & 1 deletion lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ def post(path, options={})
def post_chunked(path, options={})
authenticate(configuration + path)
result = ""

response = @client.post(configuration + path, merge_options(options)[:body], merge_options(options)[:headers]) do |chunk|
result << chunk
end
evaluate_chunk_response(response, result)

r = evaluate_chunk_response(response, result)

if r.last["status"] > 399
handle_4xx_500_response(r.last["status"], r.last["body"] || r.last )
end

r
end

def put(path, options={})
Expand Down Expand Up @@ -142,6 +150,10 @@ def handle_4xx_500_response(code, body)
parsed_body = {}
message = "No error message returned from server."
stacktrace = ""
elsif body.is_a? Hash
parsed_body = body
message = parsed_body["message"]
stacktrace = parsed_body["stacktrace"]
else
parsed_body = @parser.json(body)
message = parsed_body["message"]
Expand Down
15 changes: 9 additions & 6 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@
[:create_relationship, "has", "{0}", "{2}", {}]
batch_result.should_not be_nil


batch_result = @neo.batch [:create_unique_node, "person", "ssn", "000-00-0001", {:first_name=>"Jane", :last_name=>"Doe", :ssn=>"000-00-0001", :_type=>"Person", :created_at=>1335269478}],
[:add_node_to_index, "person_ssn", "ssn", "000-00-0001", "{0}"],
[:create_node, {:street1=>"94437 Kemmer Crossing", :street2=>"Apt. 333", :city=>"Abshireton", :state=>"AA", :zip=>"65820", :_type=>"Address", :created_at=>1335269478}],
Expand All @@ -457,22 +456,26 @@
it "should return errors when bad syntax is passed in batch" do

batch_commands = []
batch_commands << [ :create_unique_node, "person", "ssn", "000-00-0001", {:foo => "bar"} ]
# batch_commands << [ :create_unique_node, "person", "ssn", "000-00-0002", {:foo => "bar"} ]

# this doesn't raise error
batch_commands << [ :execute_query, "start person_n=node:person(ssn = '000-00-0001')
set bar = {foo}",
batch_commands << [ :execute_query, "start person_n=node:person(ssn = '000-00-0002')
set bar1 = {foo}",
{ :other => "what" }
]


# this does raise error
expect {
@neo.execute_query("start person_n=node:person(ssn = '000-00-0001')
set bar = {foo}",
{ :other => "what" })
}.to raise_exception Neography::SyntaxException

batch_result = @neo.batch *batch_commands

expect {
batch_result = @neo.batch *batch_commands
}.to raise_exception Neography::SyntaxException

end
end

Expand Down

0 comments on commit c6dad85

Please sign in to comment.