Ed Leafe wrote:
> On May 1, 2008, at 12:56 PM, Ed Leafe wrote:
>
>> I'm not sure that the problem is new(); it looks like the code in
>> setCurrentParent() is not correct. It assumes that the link is via the
>> PK, which in this case is not true.
>>
>> I'll look into it some more later and post my changes for you to
>> test.
>
> OK, after some digging, there is another problem: the code in
> setChildLinkFilter(), starting around line 849, reads:
>
> if self.DataSource and self.LinkField and self.Parent:
> if self.Parent.IsAdding or self.Parent.RowCount == 0:
> # Parent is new and not yet saved, so we cannot have child
> records
> yet.
> self.setWhereClause("")
> filtExpr = " 1 = 0 "
>
> Paul, do you agree that the assumption that a new, unsaved parent
> cannot have child records yet, is incorrect, since the child could be
> based on some other field, as it is here? Can you see any problem with
> changing the second line above to read:
>
> if self.Parent.RowCount == 0:
Here's the result of 'svn blame' in that section of the code. Sorry for
the line wrap. Left col is the line number, 2nd col is the revision.
842 299 ed def setChildLinkFilter(self):
843 2224 echo """ If this is a child bizobj, its record
set is dependent on its parent's
844 974 ed current PK value. This will add the
appropriate WHERE clause to
845 3239 paul filter the child records. If the parent is a
new, unsaved record, or if
846 3239 paul there is no parent record, there cannot be
any child records saved yet,
847 3239 paul so an empty query is built.
848 299 ed """
849 2855 paul if self.DataSource and self.LinkField and
self.Parent:
850 3239 paul if self.Parent.IsAdding or
self.Parent.RowCount == 0:
851 974 ed # Parent is new and not yet saved, so we
cannot have child records yet.
852 3016 ed self.setWhereClause("")
853 974 ed filtExpr = " 1 = 0 "
Specifically, line 850 was changed by me in 3239. Here's that log entry:
------------------------------------------------------------------------
r3239 | paul | 2007-07-11 21:31:27 -0700 (Wed, 11 Jul 2007) | 7 lines
Changed paths:
M /trunk/dabo/biz/dBizobj.py
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.
------------------------------------------------------------------------
Here's the diff for that section of the code:
if self.DataSource and self.LinkField and self.Parent:
- if self.Parent.IsAdding:
+ if self.Parent.IsAdding or self.Parent.RowCount
== 0:
# Parent is new and not yet saved, so
we cannot have child records yet.
self.setWhereClause("")
filtExpr = " 1 = 0 "
So the answer to your question is: "I don't know." I think I left the
IsAdding check there because it was there before, but added the RowCount
check because it was needed for what I was fixing. At first glance it
seems like IsAdding would only ever be True when there's a row, so it
wouldn't matter.
I hope this helps!
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]