sparna-git / Sparnatural

Sparnatural : visual knowledge graph explorer with SPARQL, in the browser, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
225 stars 41 forks source link

Modifying example query with aggregation fails #646

Open ch-sander opened 1 month ago

ch-sander commented 1 month ago

If I load a preset query with a count and then modify this query, I will get an error in the console and the UI for the aggregation empties:

SparqlGenerator.ts:55 Uncaught TypeError: Cannot read properties of undefined (reading 'selectedVariable')
    at po.generateQuery (SparqlGenerator.ts:55:39)
    at fo.generateQuery (GenerateQuery.ts:51:32)
    at HTMLDivElement.<anonymous> (ActionStore.ts:52:34)
    at RemoveEndClass.ts:45:22
    at HTMLLIElement.<anonymous> (GroupWrapperEventStore.ts:36:9)
    at ClassTypeId.ts:118:20
    at HTMLSpanElement.<anonymous> (UnselectBtn.ts:10:7)
    at HTMLSpanElement.dispatch (jquery.js:5430:27)
    at e.9755.S.event.add.m.handle (jquery.js:5234:28)

example query:

{
  "distinct": true,
  "variables": [
    {
      "expression": {
        "type": "aggregate",
        "aggregation": "count",
        "distinct": false,
        "expression": {
          "termType": "Variable",
          "value": "institution_1"
        }
      },
      "variable": {
        "termType": "Variable",
        "value": "institution_1_count"
      }
    },
    {
      "termType": "Variable",
      "value": "region_4"
    }
  ],
  "order": null,
  "branches": [
    {
      "line": {
        "s": "institution_1",
        "p": "http://www.graceful17.org/shacl/sparnatural-config/primary_place",
        "o": "place_2",
        "sType": "http://www.graceful17.org/shacl/sparnatural-config/institution",
        "oType": "http://www.graceful17.org/shacl/sparnatural-config/place",
        "values": []
      },
      "children": [
        {
          "line": {
            "s": "place_2",
            "p": "http://www.graceful17.org/shacl/sparnatural-config/falls_within",
            "o": "region_4",
            "sType": "http://www.graceful17.org/shacl/sparnatural-config/place",
            "oType": "http://www.graceful17.org/shacl/sparnatural-config/region",
            "values": []
          },
          "children": []
        }
      ]
    }
  ]
}

grafik

tfrancart commented 1 month ago

I cannot reproduce. Could you be more precise on the sequence of action you are taking to reproduce the bug ? what exactly are you modifying after loading the query ?

ch-sander commented 1 month ago

Sure!

https://github.com/user-attachments/assets/55695b72-77a0-4d93-a1b2-c18520861219

  1. I open (or create) a query that has more than one branch. I used one that has a count aggregation, but maybe that's not even the issue.
  2. I delete on line/branch in the query
  3. the panel for aggregation/sort will then be empty. The query still works, though.