#1 2017-11-26 04:16:06

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Typo in example code of many-to-many relationship in the documentation

https://synopse.info/files/html/Synopse … 01.18.html

...
5.5.2.2.1. Introducing TSQLRecordMany
...

    for i := 1 to high(dID) do
    begin
      Check(MS.DestList.SourceGet(aClient,dID[i],res));
      if not Check(length(res)=1) then   <<<<<<<<<<<<<<<<<<<<<<<<<<< should be CheckFailed as shown in SynSelfTests.pas
        Check(res[0]=sID[i]);
      Check(MS.DestList.ManySelect(aClient,sID[i],dID[i]));
      Check(MS.DestList.AssociationTime=i);
    end;
for i := 1 to high(sID) do
begin
  Check(MS.DestList.DestGet(aClient,sID[i],res));
  if Check(length(res)=1) then   <<<<<<<<<<<<<<<<<<<<<<<<<<< should be CheckFailed as shown in SynSelfTests.pas
    continue; // avoid GPF
  Check(res[0]=dID[i]);

big_smile

Offline

#2 2017-11-26 07:59:03

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Typo in example code of many-to-many relationship in the documentation

Another typo

    /// retrieve all records associated to a particular Dest record, which
    // has a TSQLRecordMany property
    // - returns the Count of records corresponding to this aSource record    <<<<<<<<<<<<<<<<<<<<<<< "this aSource record" should be "this aDest record" ?
    // - use a "for .." loop or a "while FillOne do ..." loop to iterate
    // through all Dest items, getting also any additional 'through' columns    <<<<<<<<<<<<<<<<<<<<<<< "through all Dest items" should be "through all Source items" ?
    // - the optional aAndWhereSQL parameter can be used to add any additional
    // condition to the WHERE statement (e.g. 'Salary>:(1000): AND Salary<:(2000):')
    // according to TSQLRecordMany properties - note that you should better use
    // inlined parameters for faster processing on server, so you may call e.g.
    // ! aRec.FillManyFromDest(Client,DestID,FormatUTF8('Salary>? AND Salary<?',[],[1000,2000]));
    function FillManyFromDest(aClient: TSQLRest; aDestID: TID;
      const aAndWhereSQL: RawUTF8=''): integer;

Moreover, would you also include test for FillManyFromDest in SynSelfTests.pas ? big_smile

Offline

Board footer

Powered by FluxBB