Friday, March 19, 2010

Query.pack method parameter

The comment from here forced me to pay attention to the Boolean parameter on the Query.pack() method which I didn't mention before. It is not obvious what it does by looking at its name - _doCheck. I tried to figure out what it does and I've got the following:
If a query contains DynaLink then calling Query.pack(true) will throw the error: Attempting to pack a query that contains one or more dynamic links.
If a query contains DynaLink then calling Query.pack(false) will succeed and DynaLink will not be stored in the package - it will not appear on a new query created from the package.

Does anybody have more information on this parameter?

Example:
public static void testQueryPack()
{
    InventItemGroup itemGroup;
    Query q1 = new Query();
    Query q2;
    QueryBuildDataSource qbds;

    qbds = q1.addDataSource(tablenum(InventTable));
    qbds.addDynalink(fieldnum(InventTable, ItemGroupId), itemGroup, fieldnum(InventItemGroup, ItemGroupId));
    info(qbds.toString());

    q2 = new Query(q1.pack(false));
    qbds = q2.dataSourceTable(tablenum(InventTable));
    info(qbds.toString());
}

Result:

5 comments: