Page 1 of 1
Read only fields not really read only
Posted: 07.03.2008, 13:14
by btrewern
It seems that setting a field's ReadOnly property to true on a Zeos dataset does not actually make the field read only.
Code: Select all
ZQuery1.Edit;
ZQuery1id.ReadOnly := True;
ZQuery1id.Value := 1; <-- This should raise an error
ZQuery1.Post; <-- This completes.
It's not a big problem but I think it's a bug. Does anyone know where to start in trying to fix this?
Regards,
Ben
Posted: 07.03.2008, 16:09
by btrewern
After a little digging I think I've found a fix:
Change ZAbstractRODataset.SetFieldData to read:
Code: Select all
procedure TZAbstractRODataset.SetFieldData(Field: TField; Buffer: Pointer);
var
ColumnIndex: Integer;
RowBuffer: PZRowBuffer;
WasNull: Boolean;
begin
WasNull := False;
if not Active then
raise EZDatabaseError.Create(SOperationIsNotAllowed4);
if not RequestLive and (Field.FieldKind = fkData) then
RaiseReadOnlyError;
if Field.ReadOnly and not (State = dsFilter) then -- Change is here
DatabaseErrorFmt(SFieldReadOnly, [Field.DisplayName]); -- and here
if not (State in dsWriteModes) then
DatabaseError(SNotEditing, Self);
...
...
Not well tested but seems to work here.
Regards,
Ben
Posted: 12.03.2008, 17:18
by btrewern
Added to Mantis so as to not be lost.
Posted: 12.03.2008, 21:23
by mdaems
Thanks Ben. Didn't find time yet...
What's that not (State = dsFilter) condition about? Just curious so I don't have to search that myself.
Mark
Posted: 13.03.2008, 12:02
by btrewern
It's related to OnFilterRecord. I'm not 100% sure if it's needed but I dragged it from the VCL.
Ben
Posted: 16.03.2008, 11:39
by mdaems
Done. SVN Rev. 349