I just encountered a strange problem that I guess had existed for a 
while but I hadn't noticed it before.  I have a Dabo app that uses a 
bizobj with a UserSQL string to return a custom data set --- crucially, 
a data set with different columns than the underlying table.  This is 
used as the data set for a dGrid.

        The problem comes when trying to sort by clicking on the column 
headers in the grid.  I would get an error about an invalid column for 
the sort.

        I tracked down the source of the problem.  The issue is that 
dCursorMixin uses DataStructure to determine whether the given column is 
valid for a sort.  The DataStructure code, in turn, relies on the 
BackendObject's getStructureDescription method.  But this method uses 
something called getStructureOnlySQL, and that uses getSQL --- bypassing 
the UserSQL.  The result is that, even when UserSQL is specified, the 
cursor tries to get the DataStructure by using the auto-generated SQL.  
This fails when custom SQL returns different columns than are present 
in the table, since then the actual results don't match the "structure-
only" description.

        I'm not sure what the best solution for this is.  Probably there's 
no generic way to get the structure if there's a custom UserSQL.  
However, it would seem there's some sort of mistiming about when this 
stuff is getting queried.  The "structure only SQL" is only used if no 
data query has yet been issued.  But in my app, the data did in fact 
show up in the dGrid --- and, if I used the dabo command window to check 
the backend object's structure, it was correct.  So it seems as if dabo 
is trying to get the structure-only SQL before doing the query, even 
though it needs to do the query anyway to populate the dGrid.

        Is there some method of "refreshing" the DataStructure that could 
be used in these cases?  I found that if I just set the cursor's 
internal _dataStructure attribute to None, subsequent reads of 
DataStructure would read the correct structure.  So the problem is that 
dabo is caching an invalid structure.

-- 
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail."
        --author unknown

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to