From 2418e70c746ec47483117d57d1a2d475132fc54e Mon Sep 17 00:00:00 2001 From: Gerhard Fobe Date: Wed, 20 Jun 2012 13:51:49 +0200 Subject: [PATCH] fix part of issue #22: do not double-quote graph uri in _execSparql --- Erfurt/Store/Adapter/Virtuoso.php | 3 ++- tests/Erfurt/Store/Adapter/VirtuosoTest.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Erfurt/Store/Adapter/Virtuoso.php b/Erfurt/Store/Adapter/Virtuoso.php index 418fa1a1..2f7eec51 100644 --- a/Erfurt/Store/Adapter/Virtuoso.php +++ b/Erfurt/Store/Adapter/Virtuoso.php @@ -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. @@ -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) { diff --git a/tests/Erfurt/Store/Adapter/VirtuosoTest.php b/tests/Erfurt/Store/Adapter/VirtuosoTest.php index 81b4491f..d2cace37 100644 --- a/tests/Erfurt/Store/Adapter/VirtuosoTest.php +++ b/tests/Erfurt/Store/Adapter/VirtuosoTest.php @@ -4,6 +4,9 @@ class Erfurt_Store_Adapter_VirtuosoTest extends Erfurt_TestCase { + /** + * @var Erfurt_Store_Adapter_Virtuoso + */ public $fixture = null; public function setUp() @@ -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' + ); + } }