1
0
Fork 0

Bug fix 3.4/arangosh gharial vertex deletion (#9927)

* typo in route

* unused function removed

* merge

* changelog

* removed fail, removed print
This commit is contained in:
Heiko 2019-09-11 12:00:42 +02:00 committed by KVS85
parent ccfa517178
commit 4298098f56
5 changed files with 360 additions and 351 deletions

View File

@ -1,6 +1,10 @@
v3.4.9 (XXXX-XX-XX) v3.4.9 (XXXX-XX-XX)
------------------- -------------------
* Fixed the removal (including a collection drop) of an orphanCollection from a
graph definition when using the arango shell. The boolean flag whether to drop
the collection or not was not transferred properly.
* Fixed internal issue #633: made ArangoSearch functions BOOST, ANALYZER, MIN_MATCH * Fixed internal issue #633: made ArangoSearch functions BOOST, ANALYZER, MIN_MATCH
callable with constant arguments. This will allow running queries where all arguments callable with constant arguments. This will allow running queries where all arguments
for these functions are deterministic and do not depend on loop variables. for these functions are deterministic and do not depend on loop variables.

View File

@ -119,9 +119,9 @@ CommonGraph.prototype._addVertexCollection = function (name, createCollection) {
CommonGraph.prototype._removeVertexCollection = function (name, dropCollection) { CommonGraph.prototype._removeVertexCollection = function (name, dropCollection) {
let uri = GRAPH_PREFIX + encodeURIComponent(this.__name) + "/vertex/" + encodeURIComponent(name); let uri = GRAPH_PREFIX + encodeURIComponent(this.__name) + "/vertex/" + encodeURIComponent(name);
if (dropCollection === true) { if (dropCollection === true) {
uri += "?dropCollections=true"; uri += "?dropCollection=true";
} else { } else {
uri += "?dropCollections=false"; uri += "?dropCollection=false";
} }
const requestResult = arangosh.checkRequestResult(db._connection.DELETE(uri)); const requestResult = arangosh.checkRequestResult(db._connection.DELETE(uri));
const graph = requestResult.graph; const graph = requestResult.graph;

View File

@ -1566,44 +1566,6 @@ class Graph {
return this.__orphanCollections; return this.__orphanCollections;
} }
// //////////////////////////////////////////////////////////////////////////////
// / @brief was docuBlock JSF_general_graph__removeVertexCollection
// //////////////////////////////////////////////////////////////////////////////
_removeVertexCollection (vertexCollectionName, dropCollection) {
var err;
if (db._collection(vertexCollectionName) === null) {
err = new ArangoError();
err.errorNum = arangodb.errors.ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST.code;
err.errorMessage = arangodb.errors.ERROR_GRAPH_VERTEX_COL_DOES_NOT_EXIST.message;
throw err;
}
var index = this.__orphanCollections.indexOf(vertexCollectionName);
if (index === -1) {
err = new ArangoError();
err.errorNum = arangodb.errors.ERROR_GRAPH_NOT_IN_ORPHAN_COLLECTION.code;
err.errorMessage = arangodb.errors.ERROR_GRAPH_NOT_IN_ORPHAN_COLLECTION.message;
throw err;
}
if (dropCollection) {
checkRWPermission(vertexCollectionName);
}
this.__orphanCollections.splice(index, 1);
delete this[vertexCollectionName];
db._graphs.update(this.__name, {orphanCollections: this.__orphanCollections});
if (dropCollection === true) {
var graphs = exports._listObjects();
if (checkIfMayBeDropped(vertexCollectionName, null, graphs)) {
db._drop(vertexCollectionName);
}
}
updateBindCollections(this);
}
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////
// / @brief was docuBlock JSF_general_graph_connectingEdges // / @brief was docuBlock JSF_general_graph_connectingEdges
// ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////

View File

@ -31,6 +31,7 @@
const arangodb = require('@arangodb'); const arangodb = require('@arangodb');
const expect = require('chai').expect; const expect = require('chai').expect;
const graph = require("@arangodb/general-graph"); const graph = require("@arangodb/general-graph");
const _ = require("lodash");
const db = arangodb.db; const db = arangodb.db;
describe('General graph creation', function () { describe('General graph creation', function () {
@ -66,7 +67,7 @@ describe('General graph creation', function () {
describe('with defaults', function () { describe('with defaults', function () {
let g; let g;
before(function() { before(function () {
let rel = graph._relation(en, vn, vn); let rel = graph._relation(en, vn, vn);
// Create with default options // Create with default options
g = graph._create(gn, [rel], [on]); g = graph._create(gn, [rel], [on]);
@ -138,7 +139,7 @@ describe('General graph creation', function () {
describe('adding collections later', function () { describe('adding collections later', function () {
before(function() { before(function () {
let rel = graph._relation(en2, vn2, vn2); let rel = graph._relation(en2, vn2, vn2);
g._extendEdgeDefinitions(rel); g._extendEdgeDefinitions(rel);
g._addVertexCollection(on2); g._addVertexCollection(on2);
@ -190,7 +191,7 @@ describe('General graph creation', function () {
}); });
describe('modify edge definition', function () { describe('modify edge definition', function () {
before(function() { before(function () {
// We modify the first relation by adding a new vertex collection // We modify the first relation by adding a new vertex collection
let rel = graph._relation(en, vn, vn3); let rel = graph._relation(en, vn, vn3);
g._editEdgeDefinitions(rel); g._editEdgeDefinitions(rel);
@ -225,7 +226,7 @@ describe('General graph creation', function () {
const replicationFactor = 2; const replicationFactor = 2;
const numberOfShards = 3; const numberOfShards = 3;
before(function() { before(function () {
const options = { const options = {
replicationFactor, replicationFactor,
numberOfShards numberOfShards
@ -301,7 +302,7 @@ describe('General graph creation', function () {
describe('adding collections later', function () { describe('adding collections later', function () {
before(function() { before(function () {
let rel = graph._relation(en2, vn2, vn2); let rel = graph._relation(en2, vn2, vn2);
g._extendEdgeDefinitions(rel); g._extendEdgeDefinitions(rel);
g._addVertexCollection(on2); g._addVertexCollection(on2);
@ -353,35 +354,46 @@ describe('General graph creation', function () {
}); });
describe('modify edge definition', function () { describe('modify edge definition', function () {
before(function() { before(function () {
// We modify the first relation by adding a new vertex collection // We modify the first relation by adding a new vertex collection
let rel = graph._relation(en, vn, vn3); let rel = graph._relation(en, vn, vn3);
g._editEdgeDefinitions(rel); g._editEdgeDefinitions(rel);
expect(db._collection(vn3)).to.exist; expect(db._collection(vn3)).to.exist;
}); });
describe('replication factor', function () { describe('replication factor', function () {
it(`should be ${replicationFactor} for vertex collection`, function () { it(`should be ${replicationFactor} for vertex collection`, function () {
let props = db._collection(vn3).properties(); let props = db._collection(vn3).properties();
expect(props.replicationFactor).to.equal(replicationFactor); expect(props.replicationFactor).to.equal(replicationFactor);
}); });
}); });
describe('number of shards', function () { describe('number of shards', function () {
it(`should be ${numberOfShards} for vertex collection`, function () { it(`should be ${numberOfShards} for vertex collection`, function () {
let props = db._collection(vn3).properties(); let props = db._collection(vn3).properties();
expect(props.numberOfShards).to.equal(numberOfShards); expect(props.numberOfShards).to.equal(numberOfShards);
}); });
}); });
}); });
describe('modify vertices', function () {
it(`remove a vertex collection from the graph definition and also drop the collection`, function () {
expect(db[on].name() === on);
g._removeVertexCollection(on, true);
// check that the collection is really dropped
// using collections list
var collections = db._collections();
var found = false;
_.each(collections, function (collection) {
if (collection.name() === on) {
found = true;
}
});
expect(found).to.be.false;
});
});
}); });
}); });

File diff suppressed because it is too large Load Diff