Menu

#51 SPARQL Bug Joining Optional Results

Current_SVN
open
nobody
SPARQL (15)
5
2008-03-29
2008-03-29
No

In SparqlEngine.php function joinOptionalTuples, the initial logic testing for one or more empty result sets seems wrong:

if(!$finalRes && !$res)
return array();

if(!$finalRes)
return $res;

if(!$res)
return $finalRes;

So for an optional join (where the optional results are passed in as $finalRes), if there are no results from the left graph (in which case there should be no optional results added), the entire optional result set is instead returned.

Unless I'm misunderstanding something, this should read instead:

if(!$finalRes && !$res)
return array();

if(!$finalRes || !$res)
return $res;

Discussion

  • tomheath

    tomheath - 2008-05-14

    Logged In: YES
    user_id=1857680
    Originator: NO

    Definitely a big with the handling of OPTIONALs - this fix seems to work for me but haven't tested extensively.