This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch TINKERPOP-1959-tp33 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 9f4cfc7bdbcf74fafb73a3a7de31f4fd01a591e6 Author: Matthew Allen <[email protected]> AuthorDate: Mon Aug 27 09:52:49 2018 +0100 Fixed issue where eval was added to wrong class in GraphTravesal --- .../glv/GraphTraversalSource.template | 23 ++++++++++----------- .../lib/process/graph-traversal.js | 24 ++++++++++------------ .../gremlin-javascript/lib/process/traversal.js | 3 +-- .../test/integration/traversal-test.js | 2 +- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/gremlin-javascript/glv/GraphTraversalSource.template b/gremlin-javascript/glv/GraphTraversalSource.template index e48dd67..1d3dd5d 100644 --- a/gremlin-javascript/glv/GraphTraversalSource.template +++ b/gremlin-javascript/glv/GraphTraversalSource.template @@ -84,6 +84,17 @@ class GraphTraversalSource { return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b); } <% } %> + + + /** + * Send a Gremlin-Groovy script to the server. If a script is not passed in + * then the bytecode instructions will be converted to a script and sent. + * @param {string} script The script to send to server + * @param {array} bindings Map of bindings + */ + eval(script, bindings) { + return (new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), new Bytecode(this.bytecode))).eval(script, bindings); + } } /** @@ -104,18 +115,6 @@ class GraphTraversal extends Traversal { return this; } <% } %> - - - /** - * Send a Gremlin-Groovy script to the server. If a script is not passed in - * then the bytecode instructions will be converted to a script and sent. - * @param {string} script The script to send to server - * @param {array} bindings Map of bindings - */ - eval(script, bindings) { - this.bytecode.addStep('eval', [ script, bindings ]); - return this._applyStrategies().then(() => this._getNext()); - } } function callOnEmptyTraversal(fnName, args) { diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js index aa0259b..c73405e 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/graph-traversal.js @@ -172,6 +172,17 @@ class GraphTraversalSource { return new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), b); } + + + /** + * Send a Gremlin-Groovy script to the server. If a script is not passed in + * then the bytecode instructions will be converted to a script and sent. + * @param {string} script The script to send to server + * @param {array} bindings Map of bindings + */ + eval(script, bindings) { + return (new GraphTraversal(this.graph, new TraversalStrategies(this.traversalStrategies), new Bytecode(this.bytecode))).eval(script, bindings); + } } /** @@ -1132,19 +1143,6 @@ class GraphTraversal extends Traversal { return this; } - - - /** - * Send a Gremlin-Groovy script to the server. If a script is not passed in - * then the bytecode instructions will be converted to a script and sent. - * @param {string} gremlinScript The script to send to server - * @param {array} bindings Map of bindings - * @param {*} options Options to configure the script sending - */ - eval(script, bindings) { - this.bytecode.addStep('eval', [ script, bindings ]); - return this._applyStrategies().then(() => this._getNext()); - } } function callOnEmptyTraversal(fnName, args) { diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js index d8a0761..9b88232 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js @@ -81,9 +81,8 @@ class Traversal { /** * Send a Gremlin-Groovy script to the server. If a script is not passed in * then the bytecode instructions will be converted to a script and sent. - * @param {string} gremlinScript The script to send to server + * @param {string} script The script to send to server * @param {array} bindings Map of bindings - * @param {*} options Options to configure the script sending */ eval(script, bindings) { this.bytecode.addStep('eval', [ script, bindings ]); diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js index 9d5af16..cfdc4f0 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/traversal-test.js @@ -78,7 +78,7 @@ describe('Traversal', function () { it('should submit a script and bindings and return a result', function() { var g = new Graph().traversal().withRemote(connection); - return g.V().eval('g.V().has(\'name\', name)', { name: 'marko' }).then(function (item) { + return g.eval('g.V(v1)', { v1: 1 }).then(function (item) { assert.ok(item); assert.ok(item.value instanceof Vertex); });
