Hello!
I'm a bit confused about the following constructor form of QueryResults:
QueryResults(Dataset dataset, QueryResults parent, int parentRow)
What is the purpose of the parent
and parentRow
params?
I thought that maybe they were required when using addNestedQueryResults
, however from my very basic testing It seems like they are not needed (parent) nor used (parentRow) ??
example: In the reporting module I created the following Script data source examples:
ParentA
: Here I'm passing in the nested child query results in a different order to their constructed parentRow
param, and looking at the preview the parentRow
param did not seem to make any affect to the order the nested queries were attached.
ParentB
: Here I'm not even bothering with specifying a parent
or parentRow
, and it doesn't seem to cause any problems either with the preview results.
def updateData(data, sample):
from system.report import QueryResults
DataSet = system.dataset.toDataSet
parent_qr_a = QueryResults(DataSet(["Row"],[[0],[1]]))
child_qr_a_0 = QueryResults(DataSet(["Child_0"],[["value_0"]]), parent_qr_a, 0)
child_qr_a_1 = QueryResults(DataSet(["Child_1"],[["value_1"]]), parent_qr_a, 1)
parent_qr_a.addNestedQueryResults("Child",[child_qr_a_1, child_qr_a_0])
data["ParentA"] = parent_qr_a
parent_qr_b = QueryResults(DataSet(["Row"],[[0],[1]]))
child_qr_b_0 = QueryResults(DataSet(["Child_0"],[["value_0"]]))
child_qr_b_1 = QueryResults(DataSet(["Child_1"],[["value_1"]]))
parent_qr_b.addNestedQueryResults("Child",[child_qr_b_1, child_qr_b_0])
data["ParentB"] = parent_qr_b
Then examined the Preview pane:
<?xml version="1.0" ?>
<sample-data>
<!--This is the raw data used to create the report preview.-->
<ParentA>
<row-0>
<Row>0</Row>
<Child>
<row-0>
<Child_1>value_1</Child_1>
</row-0>
</Child>
</row-0>
<row-1>
<Row>1</Row>
<Child>
<row-0>
<Child_0>value_0</Child_0>
</row-0>
</Child>
</row-1>
</ParentA>
<ParentB>
<row-0>
<Row>0</Row>
<Child>
<row-0>
<Child_1>value_1</Child_1>
</row-0>
</Child>
</row-0>
<row-1>
<Row>1</Row>
<Child>
<row-0>
<Child_0>value_0</Child_0>
</row-0>
</Child>
</row-1>
</ParentB>
<Report>
<Gateway>SGL-POTG1</Gateway>
<Name>Report</Name>
<Path>Report</Path>
<Timestamp>2024-09-10 14:33:57.733</Timestamp>
</Report>
</sample-data>