Skip to content

Commit

Permalink
fix part of issue AKSW#22: do not double-quote graph uri in _execSparql
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhard Fobe committed Jun 20, 2012
1 parent df1af44 commit 2418e70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Erfurt/Store/Adapter/Virtuoso.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function __construct($adapterOptions = array())
exit;
}

class_exists('Erfurt_Store', true);//load define()s
$this->_adapterOptions = $adapterOptions;

// Access the connection in order to check whether it works.
Expand Down Expand Up @@ -986,7 +987,7 @@ private function _execSparql($sparqlQuery, $graphUri = null)
//build Virtuoso/PL query
//$virtuosoPl = 'SPARQL ' . $sparqlQuery;

$virtuosoPl = $graphSpec . 'CALL DB.DBA.SPARQL_EVAL(\'' . $sparqlQuery . '\', \'' . $graphUri . '\', 0)';
$virtuosoPl = $graphSpec . 'CALL DB.DBA.SPARQL_EVAL(\'' . $sparqlQuery . '\', ' . $graphUri . ', 0)';
$resultId = odbc_exec($this->connection(), $virtuosoPl);
#var_dump($resultId);exit;
if (false === $resultId) {
Expand Down
14 changes: 14 additions & 0 deletions tests/Erfurt/Store/Adapter/VirtuosoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class Erfurt_Store_Adapter_VirtuosoTest extends Erfurt_TestCase
{
/**
* @var Erfurt_Store_Adapter_Virtuoso
*/
public $fixture = null;

public function setUp()
Expand Down Expand Up @@ -240,5 +243,16 @@ public function testBuildTripleString()

$this->assertEquals($expected2, $this->fixture->buildTripleString($statements2));
}

public function testSparqlQuery()
{
$arResult = $this->fixture->sparqlQuery(
'SELECT * WHERE { ?s ?p ?o } LIMIT 1'
);
$this->assertCount(
1, $arResult,
'There should be exact one result row in the array'
);
}
}

0 comments on commit 2418e70

Please sign in to comment.