From 7d7e014bfeb785e1e142f2796b9609a6148539ab Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Thu, 31 Oct 2013 16:41:49 +0100 Subject: [PATCH] Only drop vertices when dropping a graph if vertices aren't used elsewhere --- js/common/tests/shell-graph.js | 15 +++++++++++++++ js/server/modules/org/arangodb/graph.js | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/common/tests/shell-graph.js b/js/common/tests/shell-graph.js index 7d0973cc6a..43ababc2c2 100644 --- a/js/common/tests/shell-graph.js +++ b/js/common/tests/shell-graph.js @@ -68,6 +68,21 @@ function GraphCreationSuite() { graph.drop(); }, + testDroppingIfVertexCollectionIsUsedTwice : function () { + var Graph = require("org/arangodb/graph").Graph, + graph_name = "UnitTestsCollectionGraph", + other_graph_name = "UnitTestsCollectionOtherGraph", + vertex = "UnitTestsCollectionVertex", + edges = "UnitTestsCollectionEdge", + other_edges = "UnitTestsCollectionOtherEdges", + graph = new Graph(graph_name, vertex, edges), + other_graph = new Graph(other_graph_name, vertex, other_edges); + + graph.drop(); + assertTrue(arangodb.db._collection("UnitTestsCollectionVertex") !== null); + other_graph.drop(); + }, + //////////////////////////////////////////////////////////////////////////////// /// @brief test: Find Graph //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/graph.js b/js/server/modules/org/arangodb/graph.js index 49884cf767..06d5ae17c8 100644 --- a/js/server/modules/org/arangodb/graph.js +++ b/js/server/modules/org/arangodb/graph.js @@ -555,7 +555,10 @@ Graph.prototype.drop = function (waitForSync) { gdb.remove(this._properties, true, waitForSync); - this._vertices.drop(); + if (gdb.byExample({vertices: this._vertices.name()}).count() === 0) { + this._vertices.drop(); + } + this._edges.drop(); };