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

Possible issue with Batch query interface (this time with a failing test) #92

Merged
merged 2 commits into from
Apr 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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