Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPTIONAL construct triggers javascript error #101

Open
Public-Health-Bioinformatics opened this issue Jul 9, 2015 · 2 comments
Open

OPTIONAL construct triggers javascript error #101

Public-Health-Bioinformatics opened this issue Jul 9, 2015 · 2 comments

Comments

@Public-Health-Bioinformatics

When running this query which apparently has an OPTIONAL expression that doesn't match anything...

  var ifm_hasDataType = ' <http://www.semanticweb.org/damion/ontologies/IFM_ontology#hasDataType> '
  var ifm_interfaceLabel = ' <http://www.semanticweb.org/damion/ontologies/IFM_ontology#interfaceLabel> '      
  var owl_Restriction = ' <http://www.w3.org/2002/07/owl#Restriction> '

  var sparql = 'PREFIX ifm:<http://www.semanticweb.org/damion/ontologies/IFM_ontology#>\
  SELECT ?datumId ?myDataType ?itemLabel\
   FROM NAMED <test> { GRAPH <test> { \
    ?datumId rdfs:subClassOf ?restriction.\
    ?restriction rdf:type '+owl_Restriction+'.\
    ?restriction owl:onProperty '+ifm_hasDataType+'.\
    ?restriction owl:onClass ?myDataType.\
     OPTIONAL {?datumId '+ifm_interfaceLabel +' ?itemLabel}\
}} LIMIT 100'

Ran into this error:

/Users/damion/Documents/IRIDA/node_js/node_modules/rdfstore/src/parser.js:865
for(var j=0; j<ts.triplesContext.length; j++) {
^
TypeError: Cannot read property 'length' of undefined
at peg$consts.type (/Users/damion/Documents/IRIDA/node_js/node_modules/rdfstore/src/parser.js:865:51)
at peg$parseRule (/Users/damion/Documents/IRIDA/node_js/node_modules/rdfstore/src/parser.js:3077:40)
at peg$parseRule ...
[Finished in 0.4s with exit code 1]

A possible error trap of the situation I tried: line 864 of parser.js - adding test for ts.triplesContext existence. Not sure if this is appropriate:

              if (ts.triplesContext)
                      for(var j=0; j<ts.triplesContext.length; j++) {
                          var triple = ts.triplesContext[j]
                          triple.graph = g;
                      }
@Public-Health-Bioinformatics
Copy link
Author

I should add - this is happening server-side with node.js . I'm not familiar enough with node.js yet to know if there are differences in javascript behaviour browser side vs. server side aside from file-system access.
If there is anything I/others can do to encourage development on this project - it could be worth a page on wiki to describe.
Regards,
Damion

@gertvv
Copy link

gertvv commented Sep 17, 2015

I also encountered this issue. The parser breaks when the OPTIONAL {} is nested inside a GRAPH ?g {} block. So the query

SELECT * WHERE { GRAPH ?g { ?s ?p ?o . OPTIONAL { ?o a ?thing . } } }

fails to parse, whereas the equivalent

SELECT * WHERE { GRAPH ?g { ?s ?p ?o . } OPTIONAL { GRAPH ?g { ?o a ?thing . } } }

is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant