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 cfa6c0425d928bf06f3f54b9379574ca8f22f52a Author: Stephen Mallette <[email protected]> AuthorDate: Fri Oct 5 09:42:37 2018 -0400 TINKERPOP-1959 Refactored request arg serialization to be more general --- .../lib/driver/driver-remote-connection.js | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js index 5b84b04..a1d3d42 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js @@ -125,9 +125,9 @@ class DriverRemoteConnection extends RemoteConnection { _getRequest(id, bytecode, op, args, processor) { if (args) { - args = this._adaptArgs(args); + args = this._adaptArgs(args, true); } - + return ({ 'requestId': { '@type': 'g:UUID', '@value': id }, 'op': op || 'bytecode', @@ -214,24 +214,23 @@ class DriverRemoteConnection extends RemoteConnection { * @returns {Object} * @private */ - _adaptArgs(args) { - if (Array.isArray(args)) { - return args.map(val => this._adaptArgs(val)); - } - - if (args instanceof t.EnumValue) { - return this._writer.adaptObject(args); - } - + _adaptArgs(args, protocolLevel) { if (args instanceof Object) { let newObj = {}; Object.keys(args).forEach((key) => { - newObj[key] = this._adaptArgs(args[key]); + // bindings key (at the protocol-level needs special handling. without this, it wraps the generated Map + // in another map for types like EnumValue. Could be a nicer way to do this but for now it's solving the + // problem with script submission of non JSON native types + if (protocolLevel && key === 'bindings') + newObj[key] = this._adaptArgs(args[key], false); + else + newObj[key] = this._writer.adaptObject(args[key]); }); + return newObj; } - return this._writer.adaptObject(args); + return args; } /**
