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

encode query when sending to auto_index #168

Merged
merged 1 commit into from
May 2, 2014
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
2 changes: 1 addition & 1 deletion lib/neography/rest/node_auto_indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def find_node_auto_index_by_value(key, value)
end

def query_node_auto_index(query_expression)
@connection.get("/index/auto/node/?query=%{query}" % {:query => query_expression}) || []
@connection.get("/index/auto/node/?query=%{query}" % {:query => encode(query_expression)}) || []
end

def get_node_auto_index_status
Expand Down
5 changes: 4 additions & 1 deletion spec/integration/rest_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@
it "can query a node from an automatic index" do
new_node = @neo.create_node("name" => "Max")
existing_nodes = @neo.find_node_auto_index("name:Max")
existing_nodes.collect{|n| n["self"]}.include?(new_node["self"]).should be_true
existing_nodes.collect{|n| n["self"]}.include?(new_node["self"]).should be_true
# check that more complex queries are correctly handled
existing_nodes = @neo.find_node_auto_index("name:Max OR name:Max")
existing_nodes.collect{|n| n["self"]}.include?(new_node["self"]).should be_true
end

it "can get a relationship from an automatic index" do
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/rest/node_auto_indexes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class Rest
it "finds by query if no value passed to #find_or_query" do
subject.connection.should_receive(:get).with("/index/auto/node/?query=some_query")
subject.find_node_auto_index("some_query")

query = "some_query AND another_one"
subject.connection.should_receive(:get).with("/index/auto/node/?query=#{URI.encode(query)}")
subject.find_node_auto_index(query)
end

it "finds by key and value" do
Expand Down