peterjohnlawrence / com.inova8.odata2sparql.v4

Part of the overall odata2sparql solution, this odata2sparql.v4 module containing the olingo4 dependencies. In other words specifically for odata v4
http://inova8.com/bg_inova8.com/offerings/odata2sparql/
Apache License 2.0
5 stars 5 forks source link

When $count of expanded navigationproperty without any selected parameters then no values return because it is a cartesian not a UNION between parameters and count #175

Closed peterjohnlawrence closed 4 years ago

peterjohnlawrence commented 4 years ago

Zone?$expand=hasStationInZone($count=true)&$select=subjectId,label&$orderby=label&$skip=0&$top=135

#expandItemWhere
OPTIONAL    {
    {
        {SELECT ?Zone_s ?ZonehasStationInZone_s {
                ?Zone_s <http://in4mium.com/londontube/ref/hasStationInZone> ?ZonehasStationInZone_s .
            } LIMIT 0
        }
        VALUES(?ZonehasStationInZone_p){(<http://www.w3.org/2000/01/rdf-schema#comment>)(<http://www.w3.org/2000/01/rdf-schema#label>)(<http://www.w3.org/2003/01/geo/wgs84_pos#lat>)(<http://www.w3.org/2003/01/geo/wgs84_pos#lat_long>)(<http://www.w3.org/2003/01/geo/wgs84_pos#long>)(<http://in4mium.com/londontube/ref/osx>)(<http://in4mium.com/londontube/ref/osy>)(<http://in4mium.com/londontube/ref/postcode>)(<http://www.w3.org/1999/02/22-rdf-syntax-ns#subjectId>)}
        ?ZonehasStationInZone_s ?ZonehasStationInZone_p ?ZonehasStationInZone_o .
    }
    #expandItemWhereCount

    UNION <---------------------------- UNION added to ensure results even when first part has no values

    { SELECT ?Zone_s (COUNT(DISTINCT ?ZonehasStationInZone_s) as ?ZonehasStationInZone_count)
        WHERE {
        ?Zone_s <http://in4mium.com/londontube/ref/hasStationInZone> ?ZonehasStationInZone_s .
        } GROUP BY ?Zone_s
    }
}