dotnetrdf icon indicating copy to clipboard operation
dotnetrdf copied to clipboard

Bug: GroupBy only contain first and last item

Open jiatao99 opened this issue 3 years ago • 0 comments

In QueryBuilder.cs, as you can see, rootGroup = lastGroup, therefore, after the loop, the rootGroup only contains the first item and one child (last item).

        private void BuildGroupByClauses(SparqlQuery query)
        {
            ISparqlGroupBy rootGroup = null;
            ISparqlGroupBy lastGroup = null;

            foreach (var buildGroup in _buildGroups)
            {
                if (rootGroup == null)
                {
                    rootGroup = lastGroup = buildGroup(Prefixes);
                }
                else
                {
                    lastGroup.Child = buildGroup(Prefixes);
                }
            }

            query.GroupBy = rootGroup;
        }

All the middle items have been over written by lastGroup.Child =buildGroup(Prefixes);

Should be patched like this:

     lastGroup = lastGroup.Child =buildGroup(Prefixes);

jiatao99 avatar Aug 11 '21 18:08 jiatao99