1
0
Fork 0

Fixed behavior of graph._countCommonNeighbors with includeData true. (#5893)

This commit is contained in:
Dan Larkin-York 2018-07-18 06:35:16 -04:00 committed by Jan
parent 1513563972
commit 7929859b23
1 changed files with 14 additions and 14 deletions

View File

@ -607,7 +607,7 @@ var checkROPermission = function(c) {
let user = users.currentUser();
if (user) {
let p = users.permission(user, db._name(), c);
var err = new ArangoError();
var err = new ArangoError();
if (p === 'none') {
//print(`Denied ${user} access to ${db._name()}/${c}`);
err.errorNum = arangodb.errors.ERROR_FORBIDDEN.code;
@ -903,9 +903,9 @@ class Graph {
options = options || {};
var query = `
${transformExampleToAQL(vertexExample, Object.keys(this.__vertexCollections), bindVars, 'start')}
FOR v, e IN ${options.minDepth || 1}..${options.maxDepth || 1} ${options.direction || 'ANY'} start
FOR v, e IN ${options.minDepth || 1}..${options.maxDepth || 1} ${options.direction || 'ANY'} start
${buildEdgeCollectionRestriction(options.edgeCollectionRestriction, bindVars, this)}
${buildFilter(options.edgeExamples, bindVars, 'e')}
${buildFilter(options.edgeExamples, bindVars, 'e')}
RETURN DISTINCT ${options.includeData === true ? 'e' : 'e._id'}`;
return db._query(query, bindVars).toArray();
}
@ -922,8 +922,8 @@ class Graph {
}
}
var bindVars = {};
var query = `${transformExampleToAQL({}, Array.isArray(options.vertexCollectionRestriction) && options.vertexCollectionRestriction.length > 0 ? options.vertexCollectionRestriction : Object.keys(this.__vertexCollections), bindVars, 'start')}
${buildFilter(vertexExample, bindVars, 'start')}
var query = `${transformExampleToAQL({}, Array.isArray(options.vertexCollectionRestriction) && options.vertexCollectionRestriction.length > 0 ? options.vertexCollectionRestriction : Object.keys(this.__vertexCollections), bindVars, 'start')}
${buildFilter(vertexExample, bindVars, 'start')}
RETURN DISTINCT start`;
return db._query(query, bindVars).toArray();
}
@ -1047,20 +1047,20 @@ class Graph {
${transformExampleToAQL(vertex1Example, Object.keys(this.__vertexCollections), bindVars, 'left')}
LET leftNeighbors = (FOR v IN ${optionsVertex1.minDepth || 1}..${optionsVertex1.maxDepth || 1} ${optionsVertex1.direction || 'ANY'} left
${buildEdgeCollectionRestriction(optionsVertex1.edgeCollectionRestriction, bindVars, this)}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex1.vertexCollectionRestriction) && optionsVertex1.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex1.vertexCollectionRestriction, 'v') : ''}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex1.vertexCollectionRestriction) && optionsVertex1.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex1.vertexCollectionRestriction, 'v') : ''}
RETURN v)
${transformExampleToAQL(vertex2Example, Object.keys(this.__vertexCollections), bindVars, 'right')}
FILTER right != left
LET rightNeighbors = (FOR v IN ${optionsVertex2.minDepth || 1}..${optionsVertex2.maxDepth || 1} ${optionsVertex2.direction || 'ANY'} right
${buildEdgeCollectionRestriction(optionsVertex2.edgeCollectionRestriction, bindVars, this)}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex2.vertexCollectionRestriction) && optionsVertex2.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex2.vertexCollectionRestriction, 'v') : ''}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex2.vertexCollectionRestriction) && optionsVertex2.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex2.vertexCollectionRestriction, 'v') : ''}
RETURN v)
LET neighbors = INTERSECTION(leftNeighbors, rightNeighbors)
FILTER LENGTH(neighbors) > 0 `;
if (optionsVertex1.includeData === true || optionsVertex2.includeData === true) {
query += `RETURN {left : left, right: right, neighbors: neighbors}`;
query += `RETURN {left : left._id, right: right._id, neighbors: neighbors}`;
} else {
query += `RETURN {left : left._id, right: right._id, neighbors: neighbors[*]._id}`;
}
@ -1851,15 +1851,15 @@ class Graph {
${transformExampleToAQL(vertex1Example, Object.keys(this.__vertexCollections), bindVars, 'left')}
LET leftNeighbors = (FOR v IN ${optionsVertex1.minDepth || 1}..${optionsVertex1.maxDepth || 1} ${optionsVertex1.direction || 'ANY'} left
${buildEdgeCollectionRestriction(optionsVertex1.edgeCollectionRestriction, bindVars, this)}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex1.vertexCollectionRestriction) && optionsVertex1.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex1.vertexCollectionRestriction, 'v') : ''}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex1.vertexCollectionRestriction) && optionsVertex1.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex1.vertexCollectionRestriction, 'v') : ''}
RETURN v)
${transformExampleToAQL(vertex2Example, Object.keys(this.__vertexCollections), bindVars, 'right')}
FILTER right != left
LET rightNeighbors = (FOR v IN ${optionsVertex2.minDepth || 1}..${optionsVertex2.maxDepth || 1} ${optionsVertex2.direction || 'ANY'} right
${buildEdgeCollectionRestriction(optionsVertex2.edgeCollectionRestriction, bindVars, this)}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex2.vertexCollectionRestriction) && optionsVertex2.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex2.vertexCollectionRestriction, 'v') : ''}
OPTIONS {bfs: true, uniqueVertices: "global"}
${Array.isArray(optionsVertex2.vertexCollectionRestriction) && optionsVertex2.vertexCollectionRestriction.length > 0 ? buildVertexCollectionRestriction(optionsVertex2.vertexCollectionRestriction, 'v') : ''}
RETURN v)
LET neighbors = INTERSECTION(leftNeighbors, rightNeighbors)
FILTER LENGTH(neighbors) > 0 `;