mirror of https://gitee.com/bigwinds/arangodb
added HAS and HAS_NOT
This commit is contained in:
parent
42173af80d
commit
041b7f5daa
|
@ -1424,6 +1424,27 @@ describe ArangoDB do
|
|||
doc.parsed_response['result'].count.should eq(4)
|
||||
end
|
||||
|
||||
it "checks list of vertices of a vertex with HAS and HAS_NOT compare" do
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/vertices"
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional1\", \"compare\" : \"HAS\" } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(4)
|
||||
|
||||
|
||||
cmd = "/_api/graph/#{graph_name}/vertices"
|
||||
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional1\", \"compare\" : \"HAS_NOT\" } ] } }"
|
||||
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
|
||||
doc.code.should eq(201)
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['result'].count.should eq(1)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -1046,6 +1046,18 @@ function process_property_compare (compare) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function process_property_filter (data, num, property, collname) {
|
||||
if (property.key !== undefined && property.compare == "HAS") {
|
||||
if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";}
|
||||
data.filter += " HAS(" + collname + ", @key" + num.toString() + ") ";
|
||||
data.bindVars["key" + num.toString()] = property.key;
|
||||
return;
|
||||
}
|
||||
if (property.key !== undefined && property.compare == "HAS_NOT") {
|
||||
if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";}
|
||||
data.filter += " !HAS(" + collname + ", @key" + num.toString() + ") ";
|
||||
data.bindVars["key" + num.toString()] = property.key;
|
||||
return;
|
||||
}
|
||||
if (property.key !== undefined && property.value !== undefined) {
|
||||
if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";}
|
||||
data.filter += " " + collname + "[@key" + num.toString() + "] " +
|
||||
|
|
Loading…
Reference in New Issue