Read only fields not really read only

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Read only fields not really read only

Post 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
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post 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
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

Added to Mantis so as to not be lost.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

It's related to OnFilterRecord. I'm not 100% sure if it's needed but I dragged it from the VCL.

Ben
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Done. SVN Rev. 349
Post Reply