Changeset 3239

Show
Ignore:
Timestamp:
07/11/2007 09:31:27 PM (1 year ago)
Author:
paul
Message:

I believe this fixes ticket #1078, the issue with requerying children when there
are no records in the parent biz. It definitely fixes the test case.

John and Larry, please confirm that it is fixed and we can close the ticket.

Once confirmed, we can decide if this bugfix can/should be backported to stable.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/biz/dBizobj.py

    r3210 r3239  
    88import dabo.dException as dException 
    99from dabo.dObject import dObject 
     10 
     11 
     12NO_RECORDS_PK = "75426755-2f32-4d3d-86b6-9e2a1ec47f2c"  ## Can't use None 
    1013 
    1114 
     
    787790        """ If this is a child bizobj, its record set is dependent on its parent's 
    788791        current PK value. This will add the appropriate WHERE clause to 
    789         filter the child records. If the parent is a new, unsaved record, 
    790         there cannot be any child records saved yet, so an empty query 
    791         is built. 
     792        filter the child records. If the parent is a new, unsaved record, or if 
     793        there is no parent record, there cannot be any child records saved yet,  
     794        so an empty query  is built. 
    792795        """ 
    793796        if self.DataSource and self.LinkField and self.Parent: 
    794             if self.Parent.IsAdding
     797            if self.Parent.IsAdding or self.Parent.RowCount == 0
    795798                # Parent is new and not yet saved, so we cannot have child records yet. 
    796799                self.setWhereClause("") 
     
    12081211            pk = None 
    12091212        else: 
    1210             pk = self.getPK() 
     1213            try: 
     1214                pk = self.getPK() 
     1215            except dException.NoRecordsException: 
     1216                # There aren't any records, all children should requery to 0 records. 
     1217                # We can't set the pk to None, because None has special meaning  
     1218                # elsewhere (self.__currentCursorKey). 
     1219                pk = NO_RECORDS_PK 
     1220 
    12111221        for child in self.__children: 
    12121222            # Let the child know the current dependent PK