Description
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Query from documentation about math operators with js-style variables binding:
let v = Vars("result1", "result2");
and(
evaluate(times(2,3), v.result1),
evaluate(times(v.result1,3), v.result2)
)
❌ Return:
SERVER ERROR: Not well formed WOQL JSON-LD
Request payload from devtools:
{
"query": {
"@type": "Limit",
"limit": 10,
"query": {
"query": {
"@type": "Limit",
"limit": 10,
"query": {
"@type": "And",
"and": [
{
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 2
}
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result1"
}
},
{
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
"@type": "Value",
"variable": "result1"
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result2"
}
}
]
}
}
}
}
}
Response from devtools:
{
"@type": "api:WoqlErrorResponse",
"api:error": {
"@type": "vio:WOQLSyntaxError",
"vio:path": [
"and",
1,
"query"
],
"vio:query": {
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
"@type": "Value",
"variable": "result1"
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result2"
}
}
},
"api:message": "Not well formed WOQL JSON-LD",
"api:status": "api:failure"
}
But similar query without js-style variables bindings:
and(
evaluate(times(2,3), "v:result1"),
evaluate(times("v:result1",3), "v:result2")
)
✅ Return correct result:
[
{
"result1": {
"@type": "xsd:decimal",
"@value": 6
},
"result2": {
"@type": "xsd:decimal",
"@value": 18
}
}
]
Request payload from devtools:
{
"query": {
"@type": "Count",
"count": {
"@type": "Value",
"variable": "Count"
},
"query": {
"@type": "And",
"and": [
{
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 2
}
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result1"
}
},
{
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
"@type": "ArithmeticValue",
"variable": "result1"
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result2"
}
}
]
}
}
}
Difference between non-working (-
) and working (+
) request
{
"query": {
- "@type": "Limit",
- "limit": 10,
+ "@type": "Count",
+ "count": {
+ "@type": "Value",
+ "variable": "Count"
+ },
"query": {
"@type": "And",
"and": [
{
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 2
}
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result1"
}
},
{
"@type": "Eval",
"expression": {
"@type": "Times",
"left": {
- "@type": "Value",
+ "@type": "ArithmeticValue",
"variable": "result1"
},
"right": {
"@type": "ArithmeticValue",
"data": {
"@type": "xsd:decimal",
"@value": 3
}
}
},
"result": {
"@type": "ArithmeticValue",
"variable": "result2"
}
}
]
}
}
}
Expected behavior
- Return correct result:
[
{
"result1": {
"@type": "xsd:decimal",
"@value": 6
},
"result2": {
"@type": "xsd:decimal",
"@value": 18
}
}
]
- Or fix the documentation
Screenshots
...
Info (please complete the following information):
- terminus-server from docker-compose:
terminusdb/terminusdb-server:v11.1.14
Additional context
- Already fixed similar issue:
Can't usetimes()
and all of other math WOQL methods as described in the documentation with error:SERVER ERROR: The query you have sent has no viable mode. Some variables can not be bound under any reordering.
#2076 - Similar not fixed yet:
SYNTAX ERROR: WOQL.limit(...).evaluate is not a function terminusdb-client-js#317