Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,10 @@ private String buildStrategyArgs(final Object[] arguments) {
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
final Configuration configuration = ((OptionsStrategy) arguments[i]).getConfiguration();
if (configuration.containsKey("multilabel")) {
gremlin.append(".with(\"multilabel\")");
gremlin.append(".with('multilabel')");
}
if (configuration.containsKey("singlelabel")) {
gremlin.append(".with(\"singlelabel\")");
gremlin.append(".with('singlelabel')");
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public static Iterable<Object[]> generateTestParameters() {
{g.inject(new int[]{5, 6}).union(__.V(Arrays.asList(1, 2)), __.V(Arrays.asList(3L, new int[]{4}))),
"g.inject([5,6]).union(__.V([1,2]),__.V([3L,[4]]))"},
{g.with("timeoutMillis", 1000).V(), "g.V()"},
// source-level multilabel/singlelabel with-clause renders with single quotes
{g.with("multilabel").V(), "g.with('multilabel').V()"},
{g.with("singlelabel").V(), "g.with('singlelabel').V()"},
{g.withSideEffect("a", 1).V(), "g.withSideEffect(\"a\",1).V()"},
{g.withStrategies(ReadOnlyStrategy.instance()).V(), "g.withStrategies(ReadOnlyStrategy).V()"},
{g.withoutStrategies(ReadOnlyStrategy.class).V(), "g.withoutStrategies(ReadOnlyStrategy).V()"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public GraphTraversalSource With(string key, object? value)
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
if (key == "multilabel" || key == "singlelabel")
{
source.GremlinLang.Append($".with(\"{key}\")");
source.GremlinLang.Append($".with('{key}')");
}
return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,11 @@ private string BuildStrategyArgs(object?[] arguments)
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
if (optionsStrategy.Configuration.ContainsKey("multilabel"))
{
_gremlin.Append(".with(\"multilabel\")");
_gremlin.Append(".with('multilabel')");
}
if (optionsStrategy.Configuration.ContainsKey("singlelabel"))
{
_gremlin.Append(".with(\"singlelabel\")");
_gremlin.Append(".with('singlelabel')");
}
continue;
}
Expand Down
726 changes: 364 additions & 362 deletions gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,20 @@ public void g_WithStrategies_OptionsStrategy_V_Count()
_g.WithStrategies(new OptionsStrategy(new Dictionary<string, object> { { "timeoutMillis", 500 } })).V().Count().GremlinLang.GetGremlin());
}

[Fact]
public void g_With_multilabel_V_uses_single_quotes()
{
// source-level multilabel with-clause renders with single quotes
Assert.Equal("g.with('multilabel').V()", _g.With("multilabel").V().GremlinLang.GetGremlin());
}

[Fact]
public void g_With_singlelabel_V_uses_single_quotes()
{
// source-level singlelabel with-clause renders with single quotes
Assert.Equal("g.with('singlelabel').V()", _g.With("singlelabel").V().GremlinLang.GetGremlin());
}

[Fact]
public void g_WithStrategies_PartitionStrategy_AddV_test()
{
Expand Down
2 changes: 1 addition & 1 deletion gremlin-go/driver/graphTraversalSource.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (gts *GraphTraversalSource) With(key interface{}, value ...interface{}) *Gr
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
k := key.(string)
if k == "multilabel" || k == "singlelabel" {
source.gremlinLang.gremlin = append(source.gremlinLang.gremlin, ".with(\""+k+"\")")
source.gremlinLang.gremlin = append(source.gremlinLang.gremlin, ".with('"+k+"')")
}

return source
Expand Down
4 changes: 2 additions & 2 deletions gremlin-go/driver/gremlinlang.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,10 @@ func (gl *GremlinLang) buildStrategyArgs(args ...interface{}) string {
gl.optionsStrategies = append(gl.optionsStrategies, strategy)
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
if _, ok := strategy.configuration["multilabel"]; ok {
gl.gremlin = append(gl.gremlin, ".with(\"multilabel\")")
gl.gremlin = append(gl.gremlin, ".with('multilabel')")
}
if _, ok := strategy.configuration["singlelabel"]; ok {
gl.gremlin = append(gl.gremlin, ".with(\"singlelabel\")")
gl.gremlin = append(gl.gremlin, ".with('singlelabel')")
}
continue
}
Expand Down
10 changes: 10 additions & 0 deletions gremlin-go/driver/gremlinlang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,16 @@ func Test_GremlinLang(t *testing.T) {
},
equals: "g.V().match(\"MATCH (p:person)\",[\"name\":\"marko\"])",
},
{
name: "GTS source-level multilabel with-clause uses single quotes",
assert: func(g *GraphTraversalSource) *GraphTraversal { return g.With("multilabel").V() },
equals: "g.with('multilabel').V()",
},
{
name: "GTS source-level singlelabel with-clause uses single quotes",
assert: func(g *GraphTraversalSource) *GraphTraversal { return g.With("singlelabel").V() },
equals: "g.with('singlelabel').V()",
},
}

var testsToRun []test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class GraphTraversalSource {
const gl = new GremlinLang(this.gremlinLang);
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
if (key === 'multilabel' || key === 'singlelabel') {
gl.appendGremlin(`.with("${key}")`);
gl.appendGremlin(`.with('${key}')`);
}
return new this.graphTraversalSourceClass(
this.graph,
Expand Down
4 changes: 2 additions & 2 deletions gremlin-js/gremlin-javascript/lib/process/gremlin-lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ export default class GremlinLang {
this.optionsStrategies.push(strategy);
// Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
if (strategy.configuration['multilabel'] !== undefined) {
this.gremlin += '.with("multilabel")';
this.gremlin += ".with('multilabel')";
}
if (strategy.configuration['singlelabel'] !== undefined) {
this.gremlin += '.with("singlelabel")';
this.gremlin += ".with('singlelabel')";
}
} else {
nonOptionsStrategies.push(strategy);
Expand Down
8 changes: 8 additions & 0 deletions gremlin-js/gremlin-javascript/test/unit/gremlin-lang-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ describe('GremlinLang', function () {
});

describe('JS-specific tests', function () {
it('should render source-level multilabel with-clause using single quotes', function () {
assert.strictEqual(g.with_('multilabel').V().getGremlinLang().getGremlin(), "g.with('multilabel').V()");
});

it('should render source-level singlelabel with-clause using single quotes', function () {
assert.strictEqual(g.with_('singlelabel').V().getGremlinLang().getGremlin(), "g.with('singlelabel').V()");
});

it('should handle Long values', function () {
assert.strictEqual(g.V(new Long('9007199254740993')).getGremlinLang().getGremlin(), 'g.V(9007199254740993L)');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def with_(self, k, v=None):

# Render multilabel/singlelabel in gremlin text (temporary until these options are removed)
if k == 'multilabel' or k == 'singlelabel':
source.gremlin_lang.gremlin.extend(['.', 'with', '(', f'"{k}"', ')'])
source.gremlin_lang.gremlin.extend(['.', 'with', '(', f"'{k}'", ')'])

return source

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ class SuperStr(str):
gremlin_lang = tests[t][0].gremlin_lang.get_gremlin()
assert gremlin_lang == tests[t][1]

def test_source_multilabel_with_clause_uses_single_quotes(self):
g = traversal().with_(None)
gremlin = g.with_('multilabel').V().element_map().gremlin_lang.get_gremlin()
assert gremlin == "g.with('multilabel').V().elementMap()"

def test_source_singlelabel_with_clause_uses_single_quotes(self):
g = traversal().with_(None)
gremlin = g.with_('singlelabel').V().element_map().gremlin_lang.get_gremlin()
assert gremlin == "g.with('singlelabel').V().elementMap()"

def test_gvalue_name_cannot_be_null(self):
try:
GValue(None, [1, 2, 3])
Expand Down
Loading