Sparqlify icon indicating copy to clipboard operation
Sparqlify copied to clipboard

SQL error due to not escaped single quotes

Open patrickwestphal opened this issue 10 years ago • 0 comments

In case literals (or resources) in the Construct part contain single quotes, as in

Prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

Create View err As
  Construct {
    <http://ex.org/sth>
        a <http://ex.org/Cls> ;
        rdfs:label "A label containing 'single quotes'" .
  }

the following error is raised:

2014-05-25 22:42:16,699 DEBUG org.aksw.sparqlify.core.algorithms.SparqlSqlStringRewriterImpl: Sql Query:
    SELECT 'http://ex.org/Cls'::text "C_8", NULL::text "C_9", 'urn:x-arq:DefaultGraphNode'::text "C_5", 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'::text "C_6", 'http://ex.org/sth'::text "C_7"
    FROM
      (SELECT 1) a_1
  UNION ALL
    SELECT NULL::text "C_8", 'A label containing 'single quotes''::text "C_9", 'urn:x-arq:DefaultGraphNode'::text "C_5", 'http://www.w3.org/2000/01/rdf-schema#label'::text "C_6", 'http://ex.org/sth'::text "C_7"
    FROM
      (SELECT 1) a_2

Exception in thread "main" java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "quotes"
  Position: 299
    at org.aksw.sparqlify.core.sparql.QueryExecutionSelect.execSelect(QueryExecutionSelect.java:59)
    at org.aksw.jena_sparql_api.core.QueryExecutionBaseSelect.executeCoreSelect(QueryExecutionBaseSelect.java:146)
    at org.aksw.sparqlify.core.sparql.QueryExecutionSparqlify.executeCoreSelect(QueryExecutionSparqlify.java:182)
    at org.aksw.jena_sparql_api.core.QueryExecutionBaseSelect.executeConstructStreaming(QueryExecutionBaseSelect.java:342)
    at org.aksw.jena_sparql_api.core.QueryExecutionBaseSelect.execConstructTriples(QueryExecutionBaseSelect.java:371)
    at org.aksw.jena_sparql_api.core.utils.QueryExecutionUtils.createIteratorDumpTriples(QueryExecutionUtils.java:65)

I used the 0.6.9-SNAPSHOT version.

patrickwestphal avatar May 25 '14 20:05 patrickwestphal