View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006234 | JEDI VCL | 00 JVCL Components | public | 2013-12-04 12:52 | 2015-09-14 13:20 |
Reporter | Torbins | Assigned To | obones | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | Daily / GIT | ||||
Target Version | Fixed in Version | 3.48 | |||
Summary | 0006234: TJvMemoryData imports indexes incorrectly | ||||
Description | If records in source dataset were sorted not by index, then this indexes will be imported incorrectly by TJvMemoryData. I have added a patch, to fix this problem. | ||||
Tags | No tags attached. | ||||
2013-12-04 12:52
|
JMD Index Import fix.patch (3,227 bytes)
diff --git "a/D:\\Components\\jvclg\\jvcl\\run\\JvMemoryDataset.pas" "b/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset.pas" index cef77ee..ad49617 100644 --- "a/D:\\Components\\jvclg\\jvcl\\run\\JvMemoryDataset.pas" +++ "b/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset.pas" @@ -2008,7 +2008,7 @@ end; function TJvMemoryData.LoadFromDataSet(Source: TDataSet; RecordCount: Integer; Mode: TLoadMode; DisableAllControls: Boolean = True): Integer; var - MovedCount, I: Integer; + MovedCount, I, FinalAutoInc: Integer; SB, DB: TBookmark; begin Result := 0; @@ -2050,6 +2050,8 @@ begin Source.First; MovedCount := MaxInt; end; + + FinalAutoInc := 0; FAutoIncField := nil; // FixReadOnlyFields also sets FAutoIncField if there is any FixReadOnlyFields(False); @@ -2069,7 +2071,10 @@ begin AssignRecord(Source, Self, True); // assign AutoInc value manually (make user keep largest if source isn't sorted by autoinc field) if (FAutoIncField <> nil) and (FSrcAutoIncField <> nil) then - FAutoInc := Max(FAutoInc, FSrcAutoIncField.AsInteger); + begin + FinalAutoInc := Max(FinalAutoInc, FSrcAutoIncField.AsInteger); + FAutoInc := FSrcAutoIncField.AsInteger; //SetAutoIncFields will write this value to all fields with ftAutoInc + end; if (Mode = lmCopy) and (FApplyMode <> amNone) then FieldByName(FStatusName).AsInteger := Integer(rsOriginal); Post; @@ -2086,6 +2091,8 @@ begin FRowsAffected := 0; end; FixReadOnlyFields(True); + if Mode = lmCopy then + FAutoInc := FinalAutoInc + 1; FAutoIncField := nil; FSrcAutoIncField := nil; First; @@ -2468,7 +2475,7 @@ end; function TJvMemoryData.CopyFromDataSet: Integer; var - I, Len: Integer; + I, Len, FinalAutoInc: Integer; Original, StatusField: TField; OriginalFields: array of TField; FieldReadOnly: Boolean; @@ -2515,6 +2522,7 @@ begin if FApplyMode <> amNone then StatusField := FieldByName(FStatusName); + FinalAutoInc := 0; FAutoIncField := nil; // find first source autoinc field FSrcAutoIncField := nil; @@ -2552,7 +2560,10 @@ begin end; // assign AutoInc value manually (make user keep largest if source isn't sorted by autoinc field) if (FAutoIncField <> nil) and (FSrcAutoIncField <> nil) then - FAutoInc := Max(FAutoInc, FSrcAutoIncField.AsInteger); + begin + FinalAutoInc := Max(FinalAutoInc, FSrcAutoIncField.AsInteger); + FAutoInc := FSrcAutoIncField.AsInteger; //SetAutoIncFields will write this value to all fields with ftAutoInc + end; if FApplyMode <> amNone then StatusField.AsInteger := Integer(rsOriginal); Post; @@ -2562,6 +2573,7 @@ begin FRowsChanged := 0; FRowsAffected := 0; finally + FAutoInc := FinalAutoInc + 1; SetLength(FCopyFromDataSetFieldDefs, 0); FSaveLoadState := slsNone; EnableControls; |
|
Please try with the latest JVCL version in GIT (or daily zip) and then send us a zipped file containing the sources of an application showing the issue. |
2013-12-16 12:15
|
Jira 6234.7z (452,995 bytes) |
|
I have added a demo. |
|
This is now in GIT |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-12-04 12:52 | Torbins | New Issue | |
2013-12-04 12:52 | Torbins | File Added: JMD Index Import fix.patch | |
2013-12-13 11:10 | obones | Note Added: 0020753 | |
2013-12-13 11:10 | obones | Status | new => feedback |
2013-12-16 12:15 | Torbins | File Added: Jira 6234.7z | |
2013-12-16 12:16 | Torbins | Note Added: 0020853 | |
2013-12-16 17:48 | obones | Status | feedback => acknowledged |
2013-12-18 15:39 | obones | Note Added: 0020882 | |
2013-12-18 15:39 | obones | Status | acknowledged => resolved |
2013-12-18 15:39 | obones | Fixed in Version | => Daily / GIT |
2013-12-18 15:39 | obones | Resolution | open => fixed |
2013-12-18 15:39 | obones | Assigned To | => obones |
2015-09-14 13:20 | obones | Fixed in Version | Daily / GIT => 3.48 |