TFixedFormatDataSet and TSDFDataSet return an incoherent RecNo
Original Reporter info from Mantis: luca @olivluca
-
Reporter name: Luca Olivetti
Original Reporter info from Mantis: luca @olivluca
- Reporter name: Luca Olivetti
Description:
TFixedFormatDataSet (ancestor of TSdfDataSet) overrides GetRecNo
(correct) but it does a strange contortion instead of simply returning
FCurRec:
function TFixedFormatDataSet.GetRecNo: Longint;
var
BufPtr: TRecordBuffer;
begin
Result := -1;
if GetActiveRecBuf(BufPtr) then
Result := PRecInfo(BufPtr + FRecInfoOfs)^.RecordNumber;
end;
Why?
Background: if you have, say, 3 records (0,1 and 2), and you insert a
new record between 1 and 2, FCurRec of the new record will be 2, while
RecordNumber (hence RecNo) will be 3, with this result:
RecordNumber (RecNo) | FCurRec -----------------------+---------- 0 | 0 1 | 1 new record-> 3 | 2 2 | 3
I know that RecNo is documented not to be reliable in all cases, but it
should be with this dataset, considering that FCurRec has the "correct"
value.
For the time being I just subclass TSdfDataset and override the GetRecNo method to return FCurRec.
Additional information:
See also this mailing list thread:
http://news.gmane.org/find-root.php?message_id=54524B07.5080602%40ventoso.org
Mantis conversion info:
- Mantis ID: 27027
- Version: 2.6.4
- Fixed in version: 3.1.1
- Fixed in revision: 30467 (#2412a2fa)
- Target version: 3.0.0