diff --git a/CHANGELOG b/CHANGELOG index 390f5f0ab8..0304e6b326 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,16 @@ devel ----- +* make the ArangoShell refill its collection cache when a yet-unknown collection + is first accessed. This fixes the following problem: + + arangosh1> db._collections(); // shell1 lists all collections + arangosh2> db._create("test"); // shell2 now creates a new collection 'test' + arangosh1> db.test.insert({}); // shell1 is not aware of the collection created + // in shell2, so the insert will fail + +* make AQL `DISTINCT` not change the order of the results it is applied on + * enable JEMalloc background thread for purging and returning unused memory back to the operating system (Linux only) diff --git a/js/client/modules/@arangodb/arango-database.js b/js/client/modules/@arangodb/arango-database.js index 6a628c043b..e633c76e80 100644 --- a/js/client/modules/@arangodb/arango-database.js +++ b/js/client/modules/@arangodb/arango-database.js @@ -302,7 +302,7 @@ ArangoDatabase.prototype._collections = function () { ArangoDatabase.prototype._collection = function (id) { if (typeof id !== 'number' && - this[id] && this[id] instanceof this._collectionConstructor) { + this.hasOwnProperty(id) && this[id] && this[id] instanceof this._collectionConstructor) { return this[id]; } var url; diff --git a/js/client/modules/@arangodb/index.js b/js/client/modules/@arangodb/index.js index 923ed7af0a..f39d339b7b 100644 --- a/js/client/modules/@arangodb/index.js +++ b/js/client/modules/@arangodb/index.js @@ -90,7 +90,17 @@ exports.ArangoView = require('@arangodb/arango-view').ArangoView; if (typeof internal.arango !== 'undefined') { try { exports.arango = internal.arango; - exports.db = new exports.ArangoDatabase(internal.arango); + let db = new exports.ArangoDatabase(internal.arango); + // proxy the db object, so we can track access to non-existing collections + exports.db = new Proxy(db, { + get(target, name) { + if (!target.hasOwnProperty(name) && target[name] === undefined && typeof name === 'string') { + // unknown collection, try re-populating the cache + db._collections(); + } + return target[name]; + }, + }); internal.db = exports.db; // TODO remove } catch (err) { internal.print('cannot connect to server: ' + String(err));