TCSVDataset duplicates modified records on Close
Summary
TCSVDataset duplicates modified records on Close
System Information
- Operating system: Windows
- Processor architecture: x86-64
- Compiler version: 3.2.0 SVN 63526
- Device: Computer
Steps to reproduce
Open a TCSVDataset on an existing CSV file, modify one record, Close the dataset.
Example Project
Created by forum member wp. csvdataset_duplicate_records-cli.zip
What is the current bug behavior?
Both the original and modified record appear in the original file.
What is the expected (correct) behavior?
Only the modified version should be written.
Relevant logs and/or screenshots
See this forum article for more detail, codestack and code
Possible fixes
Implement an automatic call to TBufDataset.MergeChangeLog somewhere within TCSVDataset.Close. I did it within an onBeforeClose handler but that is not optimal since the developer has to know it's required.
Code with TCustomBufDataset.GetDatasetPacket calls TCSVDatasetReader.StoreRecord() twice, each with a different input buffer. One of those buffers, the OldValuesBuffer, only exists because MergeChangelog is not called prior to writing out the data.