View Issue Details

IDProjectCategoryView StatusLast Update
0006048JEDI VCL00 JVCL Componentspublic2014-12-04 16:36
ReporterazarubkinAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionsuspended 
Product Version3.47 
Target VersionFixed in Version 
Summary0006048: TJvMemoryData fails to update associated dataset if autoincrement key field is present
DescriptionIt 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 InformationHere 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.Insert;
DataModule1.JvMemoryData1.FieldByName('day_date').Value := SelDate;
DataModule1.JvMemoryData1.FieldByName('daytype_id').Value := 1;
DataModule1.JvMemoryData1.Post;
DataModule1.JvMemoryData1.ApplyChanges;
TagsNo tags attached.

Activities

2012-12-19 14:05

 

JvMemoryDataset.pas (88,275 bytes)

obones

2013-01-15 16:08

administrator   ~0020380

Please provide the zipped sources of a sample application showing this.

2013-01-22 16:17

 

sample.7z (62,287 bytes)

Ezekiel056

2013-01-22 16:20

reporter   ~0020409

DataModule1.JvMemoryData1.Append instead of insert wont be better?

azarubkin

2013-01-22 16:20

reporter   ~0020410

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.

azarubkin

2013-01-22 16:27

reporter   ~0020411

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.

Ezekiel056

2013-01-22 18:30

reporter   ~0020413

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.. =)

2013-01-22 18:45

 

MemoryData.rar (4,114 bytes)

Ezekiel056

2013-01-22 18:47

reporter   ~0020414

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 =)

azarubkin

2013-01-22 20:30

reporter   ~0020416

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.

obones

2013-12-16 13:01

administrator   ~0020858

So, is the bug still there in the current GIT content?

obones

2014-12-04 16:36

administrator   ~0021126

No news, suspending the issue

Issue History

Date Modified Username Field Change
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