terminusdb / terminusdb-dashboard

Dashboard for TerminusDB
Apache License 2.0
6 stars 5 forks source link

Converting WOQL-JS to WOQL-JSON to WOQL-JS did not work: `SYNTAX ERROR: WOQL.decimal is not a function` #305

Open alexander-mart opened 9 months ago

alexander-mart commented 9 months ago

After toogle mode to JSON and back to WOQL and again to JSON (two times) with example query from docs i receive error: WOQL.decimal is not a function

Doc page: https://terminusdb.com/docs/maths-based-queries-in-woql/

How to reproduce:

  1. Paste example in WOQL-mode and run: SERVER ERROR: Not well formed WOQL JSON-LD

    let v = Vars("result");
    evaluate(times(2,3), v.result)
  2. Convert to JSON:

    {
    "@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": "result"
    }
    }
  3. Convert to WOQL:

    WOQL.eval(WOQL.times({"@type":"xsd:decimal","@value":2}, {"@type":"xsd:decimal","@value":3}), "v:result")
  4. Convert to JSON:

    {
    "@type": "Eval",
    "expression": {
    "@type": "Times",
    "left": {
      "@type": "xsd:decimal",
      "@value": 2
    },
    "right": {
      "@type": "xsd:decimal",
      "@value": 3
    }
    },
    "result": {
    "@type": "ArithmeticValue",
    "variable": "result"
    }
    }
  5. Convert to WOQL:

    WOQL.eval(WOQL.times(WOQL.decimal(2), WOQL.decimal(3)), "v:result")
  6. Convert to JSON: :x: SYNTAX ERROR: WOQL.decimal is not a function

alexander-mart commented 9 months ago

From Discord:

LaurentS: We tried replacing xsd:decimal with its equivalent (according to the docs) xsd:double but it didn't help.

alexander-mart commented 8 months ago

@GavinMendelGleason Give me a hint where to look at the code that is responsible for this? I'll try to find a bug or missing method

alexander-mart commented 8 months ago

Related issue about unable to using math methods: https://github.com/terminusdb/terminusdb/issues/2076