Repository: terminusdb/terminusdb-client-python (language: python)

Issue:
Path query bug
This is probably a bug in the lexer, but for some reason relationship_to_preceding... is not recognised - splaying this out accross triples works. % should not be treated differently.

```python
    query = WOQL().path(after_uri,'general_variables,relationship_to_preceding_%28quasi%29polity,known,value', relationship)
```


Discussion / hints:
query.to_dict() gives
```
{'@type': 'Path', 'subject': {'@type': 'NodeValue', 'node': 'after_uri'}, 'pattern': {'@type': 'PathSequence', 'sequence': [{'@type': 'PathPredicate', 'predicate': 'general_variables'}, {'@type': 'PathPredicate', 'predicate': '29polity'}, {'@type': 'PathPredicate', 'predicate': 'known'}, {'@type': 'PathPredicate', 'predicate': 'value'}]}, 'object': {'@type': 'Value', 'node': 'relationship'}}
```
seems `relationship_to_preceding_%28quasi%29polity` becomes `29polity` cause % is not a `a-z` or `A-Z` so it should be include in the lexer like this: `lexer = r"[@:_\w'%]+|[\.\|\+\*\{\}\,\(\)<>]"`


After the fix query.to_dict() is:
```
{'@type': 'Path', 'subject': {'@type': 'NodeValue', 'node': 'after_uri'}, 'pattern': {'@type': 'PathSequence', 'sequence': [{'@type': 'PathPredicate', 'predicate': 'general_variables'}, {'@type': 'PathPredicate', 'predicate': 'relationship_to_preceding_%28quasi%29polity'}, {'@type': 'PathPredicate', 'predicate': 'known'}, {'@type': 'PathPredicate', 'predicate': 'value'}]}, 'object': {'@type': 'Value', 'node': 'relationship'}}
```
will put in a PR

Fix patch:
diff --git a/terminusdb_client/woqlquery/woql_core.py b/terminusdb_client/woqlquery/woql_core.py
index 501000d6..76123752 100644
--- a/terminusdb_client/woqlquery/woql_core.py
+++ b/terminusdb_client/woqlquery/woql_core.py
@@ -114,7 +114,7 @@ def _phrase_parser(tokens):
 
 def _path_tokenize(pat):
     """Tokenizes the pattern into a sequence of tokens which may be clauses or operators"""
-    lexer = r"[@:_\w']+|[\.\|\+\*\{\}\,\(\)<>]"
+    lexer = r"[@:_\w'%]+|[\.\|\+\*\{\}\,\(\)<>]"
     return re.findall(lexer, pat)
 
 


Test patch:
diff --git a/terminusdb_client/tests/test_woqlQuery.py b/terminusdb_client/tests/test_woqlQuery.py
index 5d867e9d..71b1aa15 100644
--- a/terminusdb_client/tests/test_woqlQuery.py
+++ b/terminusdb_client/tests/test_woqlQuery.py
@@ -455,6 +455,30 @@ def test_double_grouped_path_query(self):
         }
         assert woql_object.to_dict() == json_object
 
+    def test_percent_in_path(self):
+        query = WOQLQuery().path(
+            "after_uri",
+            "general_variables,relationship_to_preceding_%28quasi%29polity,known,value",
+            "relationship",
+        )
+        assert query.to_dict() == {
+            "@type": "Path",
+            "subject": {"@type": "NodeValue", "node": "after_uri"},
+            "pattern": {
+                "@type": "PathSequence",
+                "sequence": [
+                    {"@type": "PathPredicate", "predicate": "general_variables"},
+                    {
+                        "@type": "PathPredicate",
+                        "predicate": "relationship_to_preceding_%28quasi%29polity",
+                    },
+                    {"@type": "PathPredicate", "predicate": "known"},
+                    {"@type": "PathPredicate", "predicate": "value"},
+                ],
+            },
+            "object": {"@type": "Value", "node": "relationship"},
+        }
+
 
 class TestTripleBuilder:
     def test_triple_method(self, triple_opt):