View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006048||JEDI VCL||00 JVCL Components||public||2012-12-19 14:05||2014-12-04 16:36|
|Target Version||Fixed in Version|
|Summary||0006048: TJvMemoryData fails to update associated dataset if autoincrement key field is present|
|Description||It is impossible to save modified data from TJvMemoryData to its associated dataset if it contains autoincrement key fields.|
Here are the steps to reproduce:
1. Create TJvMemoryData which is associated with another dataset (I used TADODataset).
2. Make sure that another dataset has autoincrement key fields.
3. Ensure that LoadStructure property is set to True in TJvMemoryData.
4. Insert new record into TJvMemoryData.
5. Call TJvMemoryData.ApplyChanges;
It will try to assign corresponding fields in associated dataset and will fail on the key field because it is read-only.
I have uploaded my quick fix (added a check that skips read-only fields in assignment).
|Additional Information||Here is an example:|
// the key field is 'day_id', which we don't touch - it is assumed it will be filled in automatically
DataModule1.JvMemoryData1.FieldByName('day_date').Value := SelDate;
DataModule1.JvMemoryData1.FieldByName('daytype_id').Value := 1;
|Tags||No tags attached.|
JvMemoryDataset.pas (88,275 bytes)
||Please provide the zipped sources of a sample application showing this.|
sample.7z (62,287 bytes)
||DataModule1.JvMemoryData1.Append instead of insert wont be better?|
||Done, sources uploaded. It shows the idea. It shouldn't matter that "id" field is read-only - in practice, it would be read-only AND auto-increment field which gets its value from database, not from client. Our code should not touch that field.|
||I can't really see much difference between Append and Insert methods. Embarcadero help is almost identical for these. And they behave the same in my sample application.|
Maybe with Append you create a new line with empty or default values and THEN you edit them.
With Insert your declare you're going to insert a new line with given values, THEN you POST new values which will create the new record.
I suppose.. =)
MemoryData.rar (4,114 bytes)
You dont need 2 JvMemoryData to operate. Only one is need.
See the MemoryData.rar for exemple.
I also tested the difference between INSERT and Append.
Append will add a new record at the last position.
Insert will insert a new record just before the actual cursor pos.
Play with the 2 buttons of the example to see the differences in the DBGrid.
And check how i declared the fields on my JvMemoryData comparing to your configuration.
Good Luck =)
Thank you, Ezekiel. I've found out it myself too =)
You see, my project is the sample one, to demonstrate the bug in TJvMemoryDataset.ApplyChanges method. In real project, there is TADODataset and TJvMemoryDataset, so I DO need two TJvMemoryDatasets here to demonstrate it. One of them represents the source dataset and the other is the real TJvMemoryDataset.
||So, is the bug still there in the current GIT content?|
||No news, suspending the issue|
|2012-12-19 14:05||azarubkin||New Issue|
|2012-12-19 14:05||azarubkin||File Added: JvMemoryDataset.pas|
|2013-01-15 16:08||obones||Note Added: 0020380|
|2013-01-15 16:08||obones||Status||new => feedback|
|2013-01-22 16:17||azarubkin||File Added: sample.7z|
|2013-01-22 16:20||Ezekiel056||Note Added: 0020409|
|2013-01-22 16:20||azarubkin||Note Added: 0020410|
|2013-01-22 16:27||azarubkin||Note Added: 0020411|
|2013-01-22 18:30||Ezekiel056||Note Added: 0020413|
|2013-01-22 18:45||Ezekiel056||File Added: MemoryData.rar|
|2013-01-22 18:47||Ezekiel056||Note Added: 0020414|
|2013-01-22 20:30||azarubkin||Note Added: 0020416|
|2013-12-13 11:42||obones||Status||feedback => acknowledged|
|2013-12-16 13:01||obones||Note Added: 0020858|
|2013-12-16 13:01||obones||Status||acknowledged => feedback|
|2014-12-04 16:36||obones||Note Added: 0021126|
|2014-12-04 16:36||obones||Status||feedback => resolved|
|2014-12-04 16:36||obones||Resolution||open => suspended|
|2014-12-04 16:36||obones||Assigned To||=> obones|