Master-Detail relation broken in 6.6.2 REV270

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Master-Detail relation broken in 6.6.2 REV270

Post by gto »

Hello!

In my projects, I always do the master-detail relation using the dataset property, and then writing the SQL of detail query with parameters.

For my surprise, when I've installed the REV270 and then compiled my project, everytime I append a new record to the master table, the detail don't refresh it's contents. Then I rollback to 6.6.1 where everything works OK.

Looking deep to the code, the problem occurs in the line 1961 of ZAbstractRODataset, where the function RefreshParams was modified:

Code: Select all

{**
  Refreshes parameters and reopens the dataset.
}
procedure TZAbstractRODataset.RefreshParams;
var
  DataSet: TDataSet;
begin
  DisableControls;
  try
    if FDataLink.DataSource <> nil then
    begin
      DataSet := FDataLink.DataSource.DataSet;
      if DataSet <> nil then
        if DataSet.Active and not (DataSet.State in [dsSetKey, dsEdit, dsInsert]) then
        begin
          Refresh;
        end;
    end;
  finally
    EnableControls;
  end;
end;
The problem-line is:

if DataSet.Active and not (DataSet.State in [dsSetKey, dsEdit, dsInsert]) then

where dsEdit and dsInsert are now states that refresh will not execute. They don't exist in 6.6.1 and if I remove then, my master-detail relation works again.

My questions: Who has added this options? for what ? would this person suggest a workarround in the case query is master of another?

thanks!!
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

gto,

I'll check. I suppose you're not using SVN? Normally there you find quite detailed reference to the reason of the changes. Of course, the effect you describe above was not desired.

If I forget, please log a bug report in the bug tracker.

Mark
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi again Gto,

At home now. I just checked SVN.

This is the comment on revision 225:

Avoid open/close of detail dataset on edit of master dataset- Patch by Edwin - See http://zeos.firmos.at/viewtopic.php?t=1093

My impression:
- In case of dsInsert we should clean the detail dataset. No fetching needed, however. This would solve your problem, I suppose.
- In case of dsEdit ???

Your idea? As an experienced Zeoslib user, could you give it a try and send the patch?

Mark
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Ugh.. I was not using SVN indeed.. but now I am. And yes, leaving dsEdit and removing dsInsert seems the right choice, while works for my project too :)
Here goes the patch for REV 282:

Code: Select all

Index: src/component/ZAbstractRODataset.pas
===================================================================
--- src/component/ZAbstractRODataset.pas	(revision 282)
+++ src/component/ZAbstractRODataset.pas	(working copy)
@@ -1958,7 +1958,7 @@
     begin
       DataSet := FDataLink.DataSource.DataSet;
       if DataSet <> nil then
-        if DataSet.Active and not (DataSet.State in [dsSetKey, dsEdit, dsInsert]) then
+        if DataSet.Active and not (DataSet.State in [dsSetKey, dsEdit]) then
         begin
           Refresh;
         end;
Thanks mdaems !
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Thanks gto,

I'll change it like that as soon as I get to my home PC (which can take some days, however).

Does this solution fire sql to the database when inserting records to the master? As that's a little too much, I think. Useless to search for childs of a not yet existing parent. So maybe we should find a way to avoid this queries and just clear the dataset.
I only have no idea how to do that. Also no idea about the possibility to insert records into a resultset which has been created without query. So it's mainly an informative question...
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Hum.. It can be done, but the appending of a master that already have childs in the database isn't a strange thing, occurs when database crashes and write down only the childs, or even when you delete the master, but keep the children and want them to appear if the right key is used.

Just a thought , like your's :)
But BDE/IBX/MDO and other I've used behave like this ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Done... Commit 283.
Post Reply