This is an automated email from the ASF dual-hosted git repository.
xiazcy pushed a commit to branch gvalue-feature-tests
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/gvalue-feature-tests by this
push:
new 539d32e809 force GValue to have a name
539d32e809 is described below
commit 539d32e809d46a5b66444a8c076b63ec5a069fb2
Author: Yang Xia <[email protected]>
AuthorDate: Mon Nov 25 16:04:46 2024 -0800
force GValue to have a name
---
.../src/main/python/gremlin_python/process/traversal.py | 11 ++++-------
.../src/main/python/tests/process/test_gremlin_lang.py | 7 +++++++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/gremlin-python/src/main/python/gremlin_python/process/traversal.py
b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
index 6032b8bda8..08ad525252 100644
--- a/gremlin-python/src/main/python/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/python/gremlin_python/process/traversal.py
@@ -855,8 +855,6 @@ class GremlinLang(object):
if isinstance(arg, GValue):
key = arg.get_name()
- if key is None:
- key = f'_{self.param_count.get_and_increment()}'
if not key.isidentifier():
raise Exception(f'invalid parameter name {key}.')
@@ -1086,15 +1084,14 @@ class GremlinLang(object):
class GValue:
- def __init__(self, name=None, value=None):
- if name is not None and name.startswith('_'):
+ def __init__(self, name, value):
+ if name is None:
+ raise Exception("The parameter name cannot be None.")
+ if name.startswith('_'):
raise Exception(f'invalid GValue name {name}. Should not start
with _.')
self.name = name
self.value = value
- def is_variable(self):
- return self.name is not None
-
def get_name(self):
return self.name
diff --git a/gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
b/gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
index d4046759cf..e4c60c8bc8 100644
--- a/gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
+++ b/gremlin-python/src/main/python/tests/process/test_gremlin_lang.py
@@ -473,6 +473,13 @@ class TestGremlinLang(object):
gremlin_lang = tests[t][0].gremlin_lang.get_gremlin()
assert gremlin_lang == tests[t][1]
+ def test_gvalue_name_cannot_be_null(self):
+ g = traversal().with_(None)
+ try:
+ g.V(GValue(None, [1, 2, 3]))
+ except Exception as ex:
+ assert str(ex) == 'The parameter name cannot be None.'
+
def test_gvalue_name_dont_need_escaping(self):
g = traversal().with_(None)
try: