Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima

* Added a `Char` type to `gremlin-go` to represent the Gremlin `Character` type in `GremlinLang`.
* Restricted GraphSON and Gryo `Class` deserialization to classes registered with `ClassRegistry.register()`, `registerStrategy()` or `registerStrategies()`.
* Fixed `gremlin-javascript` to send the `language` set with `with_("language", ...)` on remote traversals instead of dropping it.
* Fixed `gremlin-go` to report a malformed or truncated GraphBinary response as a deserialization error rather than a bare decoder message.
* Added a per-request `language` option to the `gremlin-go` `RequestOptionsBuilder`, and honored `With("language", ...)` on traversals.
* Changed `gremlin-go` per-request options set via `with()` to accept any numeric type holding an integer value an `int` can hold and to ignore other values rather than panicking.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/reference/gremlin-variants.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ Some connection options can also be set on individual requests made through the
const vertices = await g.with_('timeoutMillis', 500).V().out('knows').toList()
----

The following options are allowed on a per-request basis in this fashion: `batchSize`, `bulkResults`,
The following options are allowed on a per-request basis in this fashion: `batchSize`, `bulkResults`, `language`,
`materializeProperties` and `timeoutMillis`.

NOTE: When submitting traversals through `DriverRemoteConnection`, `bulkResults` defaults to `true` per-request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default class DriverRemoteConnection extends RemoteConnection {
'batchSize',
'materializeProperties',
'bulkResults',
'language',
];
for (const strategy of strategies) {
for (const key in strategy.configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ describe('DriverRemoteConnection', function () {
assert.ok(err.statusException);
});
});
it('should send the with_() language to the server', async function () {
const g = anon.traversal().with_(connection);
await assert.rejects(g.with_('language', 'no-such-engine').inject(1).toList(), err => {
assert.strictEqual(err.statusCode, 400);
assert.strictEqual(err.statusException, 'InvalidRequestException');
assert.match(err.statusMessage, /Script engine \[no-such-engine\] is not available/);
return true;
});
});
it('should use the with_() language when it is available', async function () {
const g = anon.traversal().with_(connection);
const list = await g.with_('language', 'gremlin-lang').inject(1).toList();
assert.deepStrictEqual(list, [1]);
});
it('should iterate ordered results', async function () {
const g = anon.traversal().with_(connection);
const traversal = g.V().has('name', P.within('marko', 'peter')).values('name').order();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import assert from 'assert';
import DriverRemoteConnection from '../../lib/driver/driver-remote-connection.js';
import GremlinLang from '../../lib/process/gremlin-lang.js';
import { OptionsStrategy } from '../../lib/process/traversal-strategy.js';

describe('DriverRemoteConnection', function () {
function createConnection(capture) {
Expand Down Expand Up @@ -54,4 +55,39 @@ describe('DriverRemoteConnection', function () {

assert.strictEqual(captured.requestOptions.parameters, "['x':42]");
});

describe('language', function () {
it('does not set a language when none is configured', async function () {
let captured;
const connection = createConnection(args => captured = args);

await connection.submit(new GremlinLang().addStep('V'));

assert.strictEqual(captured.requestOptions.language, undefined);
});

it('sends the language set with with_()', async function () {
let captured;
const connection = createConnection(args => captured = args);
const gremlinLang = new GremlinLang()
.addStep('V')
.addSource('withStrategies', [new OptionsStrategy({ language: 'my-engine' })]);

await connection.submit(gremlinLang);

assert.strictEqual(captured.requestOptions.language, 'my-engine');
});

it('does not render the language into the gremlin text', async function () {
let captured;
const connection = createConnection(args => captured = args);
const gremlinLang = new GremlinLang()
.addStep('V')
.addSource('withStrategies', [new OptionsStrategy({ language: 'my-engine' })]);

await connection.submit(gremlinLang);

assert.ok(!captured.gremlin.includes('language'));
});
});
});
Loading