#1 2011-10-19 16:50:09

Sir Rufo
Member
Registered: 2011-10-14
Posts: 24

FillPrepare with some strange behavior

I just take the Sample1 to point out the strange behavior
A little bit more complex Record ;o)

  TSQLSampleRecord = class(TSQLRecord)
  private
    ...
  published
    property Time: TDateTime read fTime write fTime;
    property Name: RawUTF8 read fName write fName;
    property Question: RawUTF8 read fQuestion write fQuestion;
    property Data1: RawUTF8 read FData1 write FData1;
    property Data2: RawUTF8 read FData2 write FData2;
    property Data3: RawUTF8 read FData3 write FData3;
  end;

and the modified Method in Sample1:

{$DEFINE TESTFILL}
procedure TForm1.FindButtonClick(Sender: TObject);
var Rec: TSQLSampleRecord;
begin
{$IFDEF TESTFILL}
  Rec := TSQLSampleRecord.CreateAndFillPrepare(Database,'Name="%"',[StringToUTF8(NameEdit.Text)],'Name,Question');
  try
    // Rec.ClearProperties;  // makes no difference
    if not Rec.FillOne then
{$ELSE}
  Rec := TSQLSampleRecord.Create(Database,'Name="%"',[StringToUTF8(NameEdit.Text)]);
  try
    if Rec.ID = 0 then
{$ENDIF}
      QuestionMemo.Text := 'Not found' else
      QuestionMemo.Text := UTF8ToString(Rec.Question) + '/' +UTF8ToString(Rec.Data1) + '/' +UTF8ToString(Rec.Data3) + '/' +UTF8ToString(Rec.Data3);
  finally
    Rec.Free;
  end;
end;

Running the App in normal way I enter as name 'myname' and as message 'mymessage' and send the message
I type again the name and "Find previous message"
The Result is as expected

mymessage///

ok, that was easy, now we try this with CreateAndFillPrepare
Following the same steps as above will lead us to the following result:

myname/myname/myname/myname

It seems, that the JSONTable is a little bit to busy (and also confused) in filling the field values

Offline

#2 2011-10-19 17:10:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: FillPrepare with some strange behavior

Thanks for the report.

There was an issue in TSQLRecord.FillPrepare when the table has less columns that the filling TSQLTable (can occur e.g. when using aCustomFieldsCSV parameter in FillPrepare method).

Hope it will fix your problem.

See http://synopse.info/fossil/info/0e68516af6

Offline

#3 2011-10-19 22:26:04

Sir Rufo
Member
Registered: 2011-10-14
Posts: 24

Re: FillPrepare with some strange behavior

Yes, now it works

:o)

Offline

Board footer

Powered by FluxBB