You are not logged in.
Hi, Arnaud.
Since 20.7.2011 I didn't refreshed local copy of mORMot framework from your fossil repository, until today.
I got some unexpected behavior on my "test polygon", when calling FillRow after CreateAndFillPrepare. Inner TSQLTable is that way already fetched, so I want to reuse cached data for update. I'm doing something based on TSQLTableToGrid, so I need this "more general" approach versus ORM way.
_masterRec: TSQLRecord;
(...)
_masterRec.FillRow(nodeData^.RowNum); //cause of error: ID was set to 0
_masterRec.SetFieldValue('Acknowledged', '1');
_client.Update(_masterRec); //error: this line then fails
(...)
The reason why the upper code does not work is in next code:
unit SQLite3Commons, line 11262
procedure TSQLRecordFill.Fill(aTableRow: PPUtf8CharArray);
var f: integer;
begin
if (self=nil) or (aTableRow=nil) then
exit;
for f := 0 to fTableMapCount-1 do
with fTableMap[f] do
if DestField=nil then
Dest.ID := GetInteger(aTableRow[TableIndex]) else
DestField^.SetValue(Dest,aTableRow[TableIndex]);
end;
In database table are some columns which do not map to the published properties of my TSQLRecord descendant and they evaluate to the fTableMap[f].DestField=nil too, what is setting Dest.ID to false 0 value.
I changed condition:
if DestField=nil then
to the (if the ID is set, don't set it any more):
if (DestField=nil) and (Dest.ID = 0) then
Update:
This is not ok, because if I call several times in a roll FillRow on same TSQLRecord, then the ID is not fetched.
Some other, better identification is needed (f=0 or first occurrence of DestField=nil) to distinguish between RowID/ID field and "not mapped" fields, which (I think so) always come after ID field. For me it works either solution, but you will now what is best in several cases which may appear.
Last edited by Leander007 (2012-01-06 08:45:34)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
Try this modification:
http://synopse.info/fossil/info/b5a5919070
I think it will fix the issue.
Thanks for the detailed report.
Offline
Yes it works and seems as more complete solution .
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline