Subject | TField.ReadOnly and change in TIBODataset |
---|---|
Author | pi3k14 |
Post date | 2006-09-11T07:13:24Z |
We recently changed the version of IBObjects we are using, and found
the following "fix" in IBODataset.pas TIBODataset.InternalSetFieldData
old version
if ReadOnly and not (State in [dsSetKey, dsFilter]) then
DatabaseErrorFmt(SFieldReadOnly, [Field.DisplayName]);
new version
if Field.ReadOnly and not (State in [dsSetKey, dsFilter]) then
DatabaseErrorFmt(SFieldReadOnly, [Field.DisplayName]);
there has been a change from checking the readonly of the dataset to
checking the readonly of the field, using Field.CanModify would be
the correct call, but I think the "fix" is wrong alltogether. The
TField.ReadOnly property is not intended to be used by the dataset
(data abstraction layer) at all, but by components put above these
(like visual controls).
This change prohibit the usual habit of setting the foreign key
fields of a detail dataset to readonly and it prohibit insert into
any dataset having a readonly field.
The TDataSet that TIBODataset is intended to simulate does not have
this limitation at all, the following code is completely legal.
(TField for Modul is ReadOnly, IBTable1 is TIBTable component).
IBTable1->Open();
IBTable1->First();
IBTable1->Edit();
IBTable1->FieldValues["Modul"] = "Test";
IBTable1->Close();
IBTable1->Open();
IBTable1->Insert();
IBTable1->FieldValues["Modul"] = "Test";
IBTable1->Close();
I think this change shall be rolled back, and maybe change the error
message a bit.
frode
the following "fix" in IBODataset.pas TIBODataset.InternalSetFieldData
old version
if ReadOnly and not (State in [dsSetKey, dsFilter]) then
DatabaseErrorFmt(SFieldReadOnly, [Field.DisplayName]);
new version
if Field.ReadOnly and not (State in [dsSetKey, dsFilter]) then
DatabaseErrorFmt(SFieldReadOnly, [Field.DisplayName]);
there has been a change from checking the readonly of the dataset to
checking the readonly of the field, using Field.CanModify would be
the correct call, but I think the "fix" is wrong alltogether. The
TField.ReadOnly property is not intended to be used by the dataset
(data abstraction layer) at all, but by components put above these
(like visual controls).
This change prohibit the usual habit of setting the foreign key
fields of a detail dataset to readonly and it prohibit insert into
any dataset having a readonly field.
The TDataSet that TIBODataset is intended to simulate does not have
this limitation at all, the following code is completely legal.
(TField for Modul is ReadOnly, IBTable1 is TIBTable component).
IBTable1->Open();
IBTable1->First();
IBTable1->Edit();
IBTable1->FieldValues["Modul"] = "Test";
IBTable1->Close();
IBTable1->Open();
IBTable1->Insert();
IBTable1->FieldValues["Modul"] = "Test";
IBTable1->Close();
I think this change shall be rolled back, and maybe change the error
message a bit.
frode